@tom thanks for your comments!  You are right, I didn’t mention the gpu, I will modify my first ticket in order to add and also I would like to clarify that the intention of this code is to create the forward and backward in c++, in order to speed up my python code but I am working on python with pytorch 0.4.1.
Regarding my troubles:

I was trying to use the torch::Tensor, but I think is not included in pytorch 0.4.1, right?
new_zeros is not working, I am suppose that is because I am still using at::tensor.
My code is working with the .toCLong() you mention in your first comment. But I would like to use the accessor you mention before, but I was not able to obtain the dim. I was trying to use this 5, the reason of to use the accessor is that I am trying to speed up my code.