Meta learning weight update

I have a neural network. I calculated gradient for some layers with loss1. While calculating gradient I have a computational graph. With that gradient I am getting an updated weight but haven’t lost the previous computational graph and gradient of weights are also in computational graph (with create_graph=True). with this updated weight I to get a loss2 and want update weights which are not used in this calculating loss2 but used in calculating loss1. How to do this ?