Thank you so much for the pointers.
Could you also comment on this “# [RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time]” error?
I tried to use splited parameters (i.e. trainable_1 assigned to optimizer1, and trainable_2 assigned to optimizer2, while there should not be overlap btw trainable_1 and trainable_2) for different optimizers to separate the two training flow.  Where could be wrong to trigger this “Trying to backward through the graph a second time” error?  BTW, I don’t fully understand this error, and  will “retain_graph=True” be a correct fix in this case?