Namespace error on tensorflow 2.5.2

Hello,

I am trying to create an inference pipeline using TensorFlow c++ API. I have created an inference .cc file in the /tensorflow/example/ build.

I have a special requirement to read some binary files as input so I am writing a library to read and write the binary files and do some preprocessing before feeding them to the inference files. So few template functions I need to define but I don’t want them to be inside the class so I am keeping them into a namespace into a separate header file.

But I am always getting the error
namespace definition is not allowed here.

Ex -

namespace slice {
** template**
** T restore(auto data) {**
** T val;**
** // perform some operation**
** return val;**
** }**
} // namespace slice