How to call a C++ file CUDA File in Pytorch and Pass Tensors as Argument and Return Tensors?

If I rewrite custom data preprocessing or loss CUDA scripts in a C++ file and compile it with NVCC, how can I pass tensors in, and how can I return arrays from the script as tensors? I was also wondering how the tensors were represented in Pytorch, and it is possible to represent them as standard array?

Perhaps you can look into these: