Hi,
I think the simplest way is to have two different optimizers.
Each one work with the parameters of one of the two networks. Then you do your forward/backward as usual and just call .step() for the optimizer of the network you currently want to update.