How to create a config.json after saving a model

I have a similar issue where I have my model’s (nn.module) weights and I want to convert it to be huggingface compatible model so that I can use hugging face models (as .generate). From the discussions I can see that I either have to retrain again while changing (nn.module to PreTrained) or to define my config.json file. If I wrote my config.json file what should I do next to load my torch model as huggingface one?