Tutorial / codebase for models interacting while training?

I need guidance on how to get started on a research project. I want to train two models (the particular architectures aren’t important) in tandem, with the ability to have the two models pass input tokens and output token between one another during training. Is there a tutorial or codebase with this functionality for me to get started?