Passing tensors between c++ and python

Im trying to write a C++ method that takes in torch::Tensor as a parameter and makes some modifications to the tensor and returns it back. i build this with cmake and expose it to python, but im getting errors when i try to run this, how do i pass tensors between c++ and python?

Writing a custom C++ extension as described here will work.