You need to configure Python bindings using the pybind11 macros shown here: https://pytorch.org/tutorials/advanced/cpp_extension.html#binding-to-python 111
Remember to also include the extension header — #include <torch/extension.h>
I would highly recommend reading the entire tutorial (perhaps even twice) to get an understanding of all the mechanisms in play here. Lots of moving parts, and definitely not trivial.
Good luck and have fun