Essentially, I have two layers, L1 and L2 ( independent of each other ), while updating the weights of L1, I want to
use the gradient of loss with respect to weights of L2 also. One way I found of doing this is updating all the weights manually, but since in my actual code I have a lot of layers, this is very inefficient and time consuming. Is there any other way?