Pass model to C++ wrapped with SWIG

I have a C++ package that uses SWIG to generate Python wrappers. I want to write a function that takes a module as an argument. In the C++ code, the argument will be a torch::jit::script::Module. In the Python wrapper it will be a torch.jit.ScriptModule. I found some examples of doing this with pybind11, but they seemed to rely on automatic conversion defined by PyTorch. Since I need to use SWIG, it wasn’t clear how to adapt them.

If it makes the question easier, here’s an alternative way of asking it. Suppose I’m writing C++ code. I have a PyObject that represents a torch.jit.ScriptModule. What do I write to get a torch::jit::script::Module from it?