I am using two neural networks say NN1 and NN2. Output of NN1 is used in forward function of NN2 and output of forward function of NN2 is the loss required. So in the training loop if I write
loss = NN2(data) 
loss.backward()

Will this update the weights of both NN1 and NN2?