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 12 that handles all of that for you (and provide differentiable version of the pytorch optimizers as well).