Yes this code sample will work as the second set of update is from vector which is not linked to the first set of forwards. That will work fine if it’s what you want.
You can actually remove the reain_graph=True there are you don’t backprop multiple time 

But I guess I will run into memory issues.

I don’t think so, why would you?