mBART tokenizer not following expected target token order
Author: zijwang
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.17
- Platform: linux
- Python version: 3.8.12
- PyTorch version (GPU?): 1.10.2+cu113
- Tensorflow version (GPU?):
- Using GPU in script?:
- Using distributed or parallel set-up in script?:

### Who can help
Maybe  @patil-suraj @SaulLu @patrickvonplaten ?
<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.




Models:

- ALBERT, BERT, XLM, DeBERTa, DeBERTa-v2, ELECTRA, MobileBert, SqueezeBert: @LysandreJik
- T5, BART, Marian, Pegasus, EncoderDecoder: @patrickvonplaten
- Blenderbot, MBART: @patil-suraj
- Longformer, Reformer, TransfoXL, XLNet, FNet, BigBird: @patrickvonplaten
- FSMT: @stas00
- Funnel: @sgugger
- GPT-2, GPT: @patrickvonplaten, @LysandreJik
- RAG, DPR: @patrickvonplaten, @lhoestq
- TensorFlow: @Rocketknight1
- JAX/Flax: @patil-suraj
- TAPAS, LayoutLM, LayoutLMv2, LUKE, ViT, BEiT, DEiT, DETR, CANINE: @NielsRogge
- GPT-Neo, GPT-J, CLIP: @patil-suraj
- Wav2Vec2, HuBERT, SpeechEncoderDecoder, UniSpeech, UniSpeechSAT, SEW, SEW-D, Speech2Text: @patrickvonplaten, @anton-l

If the model isn't in the list, ping @LysandreJik who will redirect you to the correct contributor.

Library:

- Benchmarks: @patrickvonplaten
- Deepspeed: @stas00
- Ray/raytune: @richardliaw, @amogkam
- Text generation: @patrickvonplaten @narsil
- Tokenizers: @SaulLu
- Trainer: @sgugger
- Pipelines: @Narsil
- Speech: @patrickvonplaten, @anton-l
- Vision: @NielsRogge, @sgugger

Documentation: @sgugger

Model hub:

- for issues with a model, report at https://discuss.huggingface.co/ and tag the model's creator.

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj

For research projetcs, please ping the contributor directly. For example, on the following projects:

- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...): mBART

The problem arises when using:
* [x] the official example scripts: (give details below)
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [ ] an official GLUE/SQUaD task: (give the name)
* [x] my own task or dataset: (give details below)

## To reproduce & Expected behavior

```
from transformers import MBartTokenizerFast, MBartTokenizer
tokenizer = MBartTokenizer.from_pretrained('facebook/mbart-large-en-ro')
tokenizer.src_lang = 'en_XX'
tokenizer.tgt_lang = 'ro_RO'

print(tokenizer('haha'))
with tokenizer.as_target_tokenizer():
    print(tokenizer('haha'))
```

which returns 
```
{'input_ids': [22010, 2, 250004], 'attention_mask': [1, 1, 1]}
{'input_ids': [22010, 2, 250020], 'attention_mask': [1, 1, 1]}
```

However, per the [official doc](https://huggingface.co/transformers/v4.1.1/model_doc/mbart.html#training), the target sequence should follow the order of `[tgt_lang_code] X [eos]`, which is `[250020, 2, 22010]` in the case above.


Comments:
Hey @zijwang ! Thank you for reporting this.

Here actually the doc is wrong. Here the target tokens actually refer to  `decoder_input_ids` for which the format should be
`[tgt_lang_code] x [eos]`

But it's not required to directly pass `decoder_input_ids`, we can instead just pass `labels` which is of the format `x [eos][tgt_lang_code]`. And the `decoder_input_ids` are prepared inside the model by shifting `labels` to the right, so we get the correct format for `decoder_input_ids` i.e `[tgt_lang_code] x [eos]`.


The `with tokenizer.as_target_tokenizer():` is used to prepare `labels`, so the order is correct.  I will fix the docs and add better examples. 


Thanks, @patil-suraj . I see your point here. Having the docs updated will be helpful :)
Meanwhile, do we still need to set `decoder_start_token_id` (something like https://github.com/huggingface/transformers/blob/master/examples/pytorch/translation/run_translation_no_trainer.py#L365-L372) given `decoder_input_ids` is right-shifted input?

>  do we still need to set `decoder_start_token_id`

It's not required to set it, if you pass `labels` those will be created inside the model.

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.