T5base loss function 
Hi!

I am now using the T5-base pretrained model for translation. For the loss function, it seems that you did not get rid of the loss
for the <padding> token. (ie. you did not use ignore index in cross entropy loss). 

I used model(x_id,x_attn,y_id,y_attn).loss to get the loss from the pre-trained model. It seems that the value is the same as the crossentropy loss without ignore padding as followed.

```
#model loss
logits = temp.logits
model_loss = temp.loss
print('model_loss',model_loss)

#my loss 
_criterion= torch.nn.CrossEntropyLoss( reduction='none')# **without ignoring padding**
loss_seq = self._criterion(logits.view(-1,logits.shape[-1]), target_ids.view(-1)).view(batch_size,-1)
loss_vec = torch.mean(loss_seq ,-1).squeeze()
print('mylossvecmean',loss_vec.mean())
```
Btw, is there any example for fine-tuning T5 for translation? I failed to achieve the BLEU they showed in the paper.

Thanks!
Hey @KevinZhoutianyi,

Sorry I don't fully here exactly what the problem is. Could you add a reproducible code snippet that shows the problem? 

Regarding fine-tuning T5 for translation, there are some examples on the forum: https://discuss.huggingface.co/ I believe.<|||||>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.<|||||>I have also noticed that, and still no idea why the implemented loss function of T5 (and BART) does not set "ignore_index" ( [nn.CrossEntropyLoss](https://pytorch.org/docs/stable/generated/torch.nn.CrossEntropyLoss.html)). I think PAD token should be ignored when computing loss.<|||||>Update: I guess I have found the reason.   The implementation uses a default setting of "nn.CrossEntropyLoss" function, where the "ignore_index" is set to -100.  So, when computing the loss, you need to convert the labels pad index, shown as below:

![Screen Shot 2022-09-25 at 20 07 03](https://user-images.githubusercontent.com/27895653/192140447-d3b2994c-fa9d-441a-a3da-6f8f36689648.png). 

See: [https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Model](https://huggingface.co/docs/transformers/model_doc/t5#transformers.T5Model
)
