Solved by Linbin in post #2 
              
              
                Yes. To compile a method other than forward (and recursively compile anything it calls), add the @torch.jit.export decorator to the method. 
See torch.jit.script — PyTorch 1.9.0 documentation