Solved by albanD in post #4 
              
              
                Hi, 
Unfortunately there isn’t as the  nn.Module is by design, not functional. 
I woudl advise using a library like https://github.com/facebookresearch/higher that handles all of that for you (and provide differentiable version of the pytorch optimizers as well).