AssertionError: internal model should be a reference to self.model
Author: zhangxiann
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.2.2 
- Platform: Linux
- Python version: 3.6
- PyTorch version (GPU?): 1.7 CPU
- Tensorflow version (GPU?):
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

### Who can help

@sgugger 

<!-- 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: @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: @Rocketknight1

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

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
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

Model I am using (Bert, XLNet ...):

The problem arises when using:
* [ ] the official example scripts: (give details below)
When I run `trainer.train()` for the second time in Jyputer, it throws error:
```
AssertionError                            Traceback (most recent call last)
<ipython-input-7-3435b262f1ae> in <module>
----> 1 trainer.train()

~/data/apps/anaconda3/lib/python3.7/site-packages/transformers/trainer.py in train(self, model_path, trial)
    933 
    934             self.control = self.callback_handler.on_epoch_end(self.args, self.state, self.control)
--> 935             self._maybe_log_save_evaluate(tr_loss, model, trial, epoch)
    936 
    937             if self.args.tpu_metrics_debug or self.args.debug:

~/data/apps/anaconda3/lib/python3.7/site-packages/transformers/trainer.py in _maybe_log_save_evaluate(self, tr_loss, model, trial, epoch)
   1006 
   1007         if self.control.should_save:
-> 1008             self._save_checkpoint(model, trial, metrics=metrics)
   1009             self.control = self.callback_handler.on_save(self.args, self.state, self.control)
   1010 

~/data/apps/anaconda3/lib/python3.7/site-packages/transformers/trainer.py in _save_checkpoint(self, model, trial, metrics)
   1012         # In all cases, including ddp/dp/deepspeed, self.model is always a reference to the model we
   1013         # want to save.
-> 1014         assert _model_unwrap(model) is self.model, "internal model should be a reference to self.model"
   1015 
   1016         # Save model checkpoint

AssertionError: internal model should be a reference to self.model

```
https://huggingface.co/transformers/training.html

The tasks I am working on is:
* [ ] sequence classification
* [ ] my own task

## To reproduce

Steps to reproduce the behavior:

1. run `trainer.train()`
2. run `trainer.train()` again.

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior

<!-- A clear and concise description of what you would expect to happen. -->


Comments:
You should update your version of Transformers to solve this issue.

thanks

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.