The loss.backward() call will let Autograd calculate the gradients for both models, as the final loss is a sum of both partial losses.
You can also verify it by printing the gradients of some parameters of these models after the backward call.