This is currently not possible and



 Jingnan_Jia:

and torch.save(net, model_path) can save the weights and the structure of the network.


will not directly save the structure of the model, but would still depend on the source files (and could thus break in various ways).
You could check the experimental torch.package utility, which might fit your use case, but note that it’s experimental and you might thus encounter issues with it.