MarianForCausalLM doc example not working
Author: ydshieh
Pull request: no

## Environment info

- `transformers` version: 4.13.0.dev0
- Platform: Windows-10-10.0.19042-SP0
- Python version: 3.9.5
- PyTorch version (GPU?): 1.9.0+cpu (False)
- Tensorflow version (GPU?): 2.7.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help
  Marian: @patrickvonplaten

## Information

Model I am using: `MarianForCausalLM`


In `modeling_marian.py`, there is a doc example for `MarianForCausalLM` that is not working. See `To reproduce`.

```
            >>> from transformers import MarianTokenizer, MarianForCausalLM

            >>> tokenizer = MarianTokenizer.from_pretrained('facebook/bart-large')
            >>> model = MarianForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
            >>> assert model.config.is_decoder, f"{model.__class__} has to be configured as a decoder."
            >>> inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
            >>> outputs = model(**inputs)

            >>> last_hidden_states = outputs.last_hidden_state
```
(Is it intended to use `facebook/bart-large` for `MarianForCausalLM`?)

## To reproduce

### Error 1

```
from transformers import MarianTokenizer, MarianForCausalLM
tokenizer = MarianTokenizer.from_pretrained('facebook/bart-large')
```
Gives error: 
```
Traceback (most recent call last):
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\tmp.py", line 3, in <module>
    tokenizer = MarianTokenizer.from_pretrained('facebook/bart-large')
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\src\transformers\tokenization_utils_base.py", line 1744, in from_pretrained
    return cls._from_pretrained(
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\src\transformers\tokenization_utils_base.py", line 1879, in _from_pretrained
    tokenizer = cls(*init_inputs, **init_kwargs)
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\src\transformers\models\marian\tokenization_marian.py", line 148, in __init__
    assert Path(source_spm).exists(), f"cannot find spm source {source_spm}"
  File "C:\Users\33611\miniconda3\envs\py39\lib\pathlib.py", line 1072, in __new__
    self = cls._from_parts(args, init=False)
  File "C:\Users\33611\miniconda3\envs\py39\lib\pathlib.py", line 697, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "C:\Users\33611\miniconda3\envs\py39\lib\pathlib.py", line 681, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
```

### Error 2

```
from transformers import MarianTokenizer, MarianForCausalLM
model = MarianForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
```
Gives error: 
```
Traceback (most recent call last):
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\tmp.py", line 7, in <module>
    model = MarianForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\src\transformers\modeling_utils.py", line 1453, in from_pretrained
    model, missing_keys, unexpected_keys, mismatched_keys, error_msgs = cls._load_state_dict_into_model(
  File "C:\Users\33611\Desktop\Projects\transformers-dev-2\transformers\src\transformers\modeling_utils.py", line 1607, in _load_state_dict_into_model
    raise RuntimeError(f"Error(s) in loading state_dict for {model.__class__.__name__}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for MarianForCausalLM:
	size mismatch for decoder.embed_positions.weight: copying a param with shape torch.Size([1026, 1024]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
```

The same issue happened for 

```
model = BlenderbotForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
```
and
```
model = BlenderbotSmallForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
```
in other doc examples.

### Checkpoint loading issue (using `Helsinki-NLP/opus-mt-en-fr`)

```
from transformers import MarianTokenizer, MarianForCausalLM
model = MarianForCausalLM.from_pretrained('Helsinki-NLP/opus-mt-en-fr', add_cross_attention=False)
```
Gives warnings: 
```
Some weights of the model checkpoint at Helsinki-NLP/opus-mt-en-fr were not used when initializing MarianForCausalLM: ['model.encoder.layers.3.fc2.bias', 'model.encoder.layers.5.final_layer_norm.weight', 'model.encoder.layers.2.self_attn.q_proj.bias', 'model.encoder.layers.2.self_attn.out_proj.bias', 'model.encoder.layers.2.self_attn.k_proj.weight', 'model.encoder.layers.3.self_attn.q_proj.bias', 'model.encoder.layers.3.fc1.weight', 'model.encoder.layers.3.self_attn.k_proj.weight', 'model.encoder.layers.0.self_attn.q_proj.weight', 'model.encoder.layers.5.self_attn.v_proj.weight', ..........]
- This IS expected if you are initializing MarianForCausalLM from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing MarianForCausalLM from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Some weights of MarianForCausalLM were not initialized from the model checkpoint at Helsinki-NLP/opus-mt-en-fr and are newly initialized: ['lm_head.weight']
```
(It seems to me that something is wrong here and need some investigation)


## Expected behavior

The doc example should work with checkpoint loaded correctly.


Comments:
Similar issue for doc example in `PegasusForCausalLM`

```
        Example::

            >>> from transformers import PegasusTokenizer, PegasusForCausalLM

            >>> tokenizer = PegasusTokenizer.from_pretrained('facebook/bart-large')
            >>> model = PegasusForCausalLM.from_pretrained('facebook/bart-large', add_cross_attention=False)
```

Thanks for noticing this - the docstrings are incorrect. We should correct them. Feel free to open a PR - otherwise I'm happy to take a look next week :-)

WIP PR here - https://github.com/huggingface/transformers/pull/15079

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/master/CONTRIBUTING.md) are likely to be ignored.