If I’m understanding your use case correctly, you are sequentially calling NN1 and NN2.
If that’s the case, your code should be fine and gradients should be calculated for both models.
Basically you can treat models (like NN1 and NN2) as layers, since both are derived from nn.Module.
There will be no difference between sequentially calling e.g. nn.Linear layer instances and your models.