model_path should be ignored as the checkpoint path
Author: tsuchm
Pull request: yes

# What does this PR do?

When the directory which holds the transformer model is given the command line argument, the script `run_xnli.py` arises the following error.  This PR fixes this problem.

```sh
$ python3 run_xnli.py \
  --model_name_or_path ./NICT_BERT-base_JapaneseWikipedia_32K_BPE \
  --do_train \
  --do_eval \
  --max_seq_length 128 \
  --per_device_train_batch_size 32 \
  --learning_rate 2e-5 \
  --num_train_epochs 3 \
  --language en \
  --fp16 \
  --fp16_opt_level O2 \
  --output_dir /tmp/xnli/
(snip)
[INFO|trainer.py:1013] 2021-04-09 15:27:01,518 >> ***** Running training *****
[INFO|trainer.py:1014] 2021-04-09 15:27:01,518 >>   Num examples = 392702
[INFO|trainer.py:1015] 2021-04-09 15:27:01,518 >>   Num Epochs = 3
[INFO|trainer.py:1016] 2021-04-09 15:27:01,518 >>   Instantaneous batch size per device = 32
[INFO|trainer.py:1017] 2021-04-09 15:27:01,518 >>   Total train batch size (w. parallel, distributed & accumulation) = 256
[INFO|trainer.py:1018] 2021-04-09 15:27:01,518 >>   Gradient Accumulation steps = 1
[INFO|trainer.py:1019] 2021-04-09 15:27:01,518 >>   Total optimization steps = 4602
  0%|                                                                                                                                               | 0/4602 [00:00<?, ?it/s]/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [0,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [2,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [3,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [6,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [9,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [10,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [12,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [23,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [24,0,0] Assertion `t >= 0 && t < n_classes` failed.
/pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:108: cunn_ClassNLLCriterion_updateOutput_kernel: block: [0,0,0], thread: [29,0,0] Assertion `t >= 0 && t < n_classes` failed.
Traceback (most recent call last):
  File "run_xnli.py", line 351, in <module>
    main()
  File "run_xnli.py", line 325, in main
    train_result = trainer.train(model_path=model_path)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/trainer.py", line 1120, in train
    tr_loss += self.training_step(model, inputs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/trainer.py", line 1522, in training_step
    loss = self.compute_loss(model, inputs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/trainer.py", line 1556, in compute_loss
    outputs = model(**inputs)
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 167, in forward
    outputs = self.parallel_apply(replicas, inputs, kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 177, in parallel_apply
    return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
    output.reraise()
  File "/home/foo/.local/lib/python3.6/site-packages/torch/_utils.py", line 429, in reraise
    raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in replica 1 on device 1.
Original Traceback (most recent call last):
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/parallel/parallel_apply.py", line 61, in _worker
    output = module(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 1510, in forward
    return_dict=return_dict,
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 981, in forward
    return_dict=return_dict,
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 575, in forward
    output_attentions,
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 461, in forward
    past_key_value=self_attn_past_key_value,
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 394, in forward
    output_attentions,
  File "/home/foo/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/foo/.local/lib/python3.6/site-packages/transformers/models/bert/modeling_bert.py", line 312, in forward
    attention_scores = attention_scores + attention_mask
RuntimeError: CUDA error: device-side assert triggered

  0%|                                                                                                                                               | 0/4602 [00:30<?, ?it/s]
```

I think that the directory specified by the command line argument has already been used as the model path of the trainer, and think that it should be ignored as the checkpoint path.

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/master/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/master/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.

<!-- Your PR 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: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

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
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
No this will then make it impossible to resume from a checkpoint if you pass `--output_dir path_to_specific_checkpoint`. This should only be ignored if the checkpoints are the wrong number of labels like [here](https://github.com/huggingface/transformers/blob/45fc8c7951f978c0f8f13c8bab52c744cd5c4784/examples/text-classification/run_glue.py#L454) in run_glue.

Thanks for your comment.  I have just improved the patch according to your comment.  Could you review it again?