About converting from pytorch to C++ for prediction function

Hi, All

I have an inquiry of converting from pytorch to C++ for prediction function:

The python code is:
def predict(self, x):
with torch.no_grad():
ret = torch.max(self.D(Variable(x), cuda=self.args.cuda), 1)[1].data
return ret

The converted C++ code is:
torch::Tensor predict(torch::Tensor x) {

    torch::Tensor x1 = discriminator->forward(x, false, args.cuda)[0];

    return std::get<1>(max(x1, 1, false)).data();
  

}

After this conversion, I find the numerical results are not quite matched from pytorch to C++.
Any comments are appreciated.

Thanks in advance.