Actually, I’d have expected that you post something I can copypaste into python and run. The cpp_extension module allows nicely to have a complete snippet.
The problem I would immediately see is that
auto output =  idx_out.contiguous().data<int>();
auto input  =  xyz.contiguous().data<float>();

is not good.

You need to hang on to the tensors you have data pointers or accessors.
You need to return (and I’d recommend returning the output in select_cube) the output.
So

auto output_ =  idx_out.contiguous(); // why would this not be torch::empty(...)?
auto output = output_.data<int>();
auto input_  =  xyz.contiguous();
auto input = input_.data<float>();
...
return output_;

Best regards
Thomas