Is a bug in TFT5ForConditionalGeneration._shift_right func?
Author: TheHonestBob
Pull request: no
Labels: name: bug

### System Info

transformers==4.17.0

### Who can help?

@patrickvonplaten

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

```py
from transformers import T5Tokenizer, TFT5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("pretrained_model/t5-base-Chinese")
model = TFT5ForConditionalGeneration.from_pretrained("pretrained_model/t5-base-Chinese", from_pt=True)
decoder_label = tokenizer.batch_encode_plus(['你好我的朋友', '不好呀'], return_tensors='tf', padding='max_length', max_length=10)
decoder_input_ids = model._shift_right(inputs['input_ids'])
```

### Expected behavior

```
decoder_label is [[  259  1575  1409  1265 22557     1     0     0     0     0], [  259 17693 21839     1     0     0     0     0     0     0]]
decoder_input_ids is [[    0   259  1575  1409  1265 22557     1     0     0     0], [    0   259 17693 21839     1     0     0     0     0     0]]
T5's decoder_start_id is 0, end_id is 1, Correct decoder_input_ids should be [[    0   259  1575  1409  1265 22557     0    0     0     0], [    0   259 17693 21839     0     0     0     0     0     0]], 
```

Comments:
Hey @TheHonestBob,

Sorry I don't have access to `"pretrained_model/t5-base-Chinese"` so I'm not sure I can help you here

> Hey @TheHonestBob,
> 
> Sorry I don't have access to `"pretrained_model/t5-base-Chinese"` so I'm not sure I can help you here

this issuse is not t5 model's problem，just ._shift_right func problem, There seems to be a logic problem with this function.

@TheHonestBob If I'm getting it right, your issue is that `decoder_input_ids`, after calling `_shift_right`, should not contain the `end_id`. Is this correct?

> 

right，when decoder_input_ids doesn't be padded, _shift_right is ok, or contain the end_id is correct?

@TheHonestBob, `shift_right` is used to automatically create the `decoder_input_ids` from `labels` for training. It depends on you what you put in the labels but if your labels are correct then you can assume the `shift_right` is also correct. Note that in general T5 should be trained with EOS for fine-tuning. For pre-training it's not necessarily but won't hurt

> @TheHonestBob, `shift_right` is used to automatically create the `decoder_input_ids` from `labels` for training. It depends on you what you put in the labels but if your labels are correct then you can assume the `shift_right` is also correct. Note that in general T5 should be trained with EOS for fine-tuning. For pre-training it's not necessarily but won't hurt

thanks a lot, I get it, shift_right maybe not right, but it's return is not hurt for training.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.