Modify HF model for training

As a beginner,I have a question.
I want to modify the forward part of T5ForConditionalGeneration for my research.
However, I don’t know how to modified it and Trainer for training.
Can you please guide me on how to modify Seq2SeqTrainer and T5ForConditionalGeneration for training?
Thank you very much.

So as far as I know, you can change the T5ForConditionalGeneration class attributes if that does the job for you. Otherwise, you might have to bite the bullet and maybe create your own class. I guess it depends on what you want to change in the forward pass. If it’s involved, probably have to create your own class I think though.

For reference, this is the source code of the T5ForConditionalGeneration: