I guess you mean you have a first model that outputs what is going to be the input of a second model?
If you want to propagate an error from, let’s say, the output of the second model all the way to the first model, I think PyTorch should be doing that for you automatically,along. Of course that is if you are using PyTorch tensors all along and unless you have at some point in between some sort of detachment, or you have something like  with torch.no_grad()
I’m not sure if I understood your problem, I hope it helps.