reply myself:
I think this is a good try since the loss and hidden states are totally the same as the standard training process, and I will test the training process later.
the separate process:

Screenshot from 2022-01-10 12-27-07939×495 74.9 KB