How does T5 create the correct decoder_input_ids?

The T5PreTrainedModel._shift_right method here takes labels and prepares decoder_input_ids

Basically, all it does is,

takes labels -> add pad token at the beginning -> remove the eos -> decoder_input_ids