Bug fix: PyTorch loading from TF and vice-versa
Author: thomwolf
Pull request: yes

Fix loading a PyTorch model from TF and vice-versa when model architectures are not the same

Fix #2109

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=h1) Report
> Merging [#2192](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/d8034092153a6850052862f154a398b88b8ba4e5?src=pr&el=desc) will **increase** coverage by `1.12%`.
> The diff coverage is `33.33%`.

[![Impacted file tree graph](https://codecov.io/gh/huggingface/transformers/pull/2192/graphs/tree.svg?width=650&token=9qOlN6Hb1c&height=150&src=pr)](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2192      +/-   ##
==========================================
+ Coverage   80.21%   81.33%   +1.12%     
==========================================
  Files         120      120              
  Lines       18254    18261       +7     
==========================================
+ Hits        14642    14853     +211     
+ Misses       3612     3408     -204
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [transformers/modeling\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX3V0aWxzLnB5) | `92.3% <0%> (ø)` | :arrow_up: |
| [transformers/modeling\_tf\_pytorch\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX3B5dG9yY2hfdXRpbHMucHk=) | `92.15% <37.5%> (+82.56%)` | :arrow_up: |
| [transformers/modeling\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX29wZW5haS5weQ==) | `81.45% <0%> (+1.32%)` | :arrow_up: |
| [transformers/modeling\_ctrl.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX2N0cmwucHk=) | `96.47% <0%> (+2.2%)` | :arrow_up: |
| [transformers/modeling\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3hsbmV0LnB5) | `74.54% <0%> (+2.32%)` | :arrow_up: |
| [transformers/modeling\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3JvYmVydGEucHk=) | `71.76% <0%> (+12.35%)` | :arrow_up: |
| [transformers/tests/modeling\_tf\_common\_test.py](https://codecov.io/gh/huggingface/transformers/pull/2192/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rlc3RzL21vZGVsaW5nX3RmX2NvbW1vbl90ZXN0LnB5) | `97.41% <0%> (+17.24%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=footer). Last update [d803409...2dd30a3](https://codecov.io/gh/huggingface/transformers/pull/2192?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Great, this works!