Clean up input embeddings resizing and weights tying
Author: thomwolf
Pull request: yes

Still need to add tests on these features

Comments:
I have added a test suite that tests both the `tie_weights` function as well as the `resize_token_embeddings`

# [Codecov](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781?src=pr&el=h1) Report
> Merging [#781](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781?src=pr&el=desc) into [xlnet](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/commit/50e62a4cb4d503e3559b88838b8cf9f745fef516?src=pr&el=desc) will **decrease** coverage by `0.23%`.
> The diff coverage is `93.05%`.

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

```diff
@@            Coverage Diff            @@
##            xlnet    #781      +/-   ##
=========================================
- Coverage   78.84%   78.6%   -0.24%     
=========================================
  Files          35      34       -1     
  Lines        6092    6122      +30     
=========================================
+ Hits         4803    4812       +9     
- Misses       1289    1310      +21
```


| [Impacted Files](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pytorch\_transformers/modeling\_xlnet.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvbW9kZWxpbmdfeGxuZXQucHk=) | `78.79% <100%> (+0.44%)` | :arrow_up: |
| [pytorch\_transformers/tests/modeling\_xlnet\_test.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvdGVzdHMvbW9kZWxpbmdfeGxuZXRfdGVzdC5weQ==) | `95.86% <100%> (+0.08%)` | :arrow_up: |
| [...rch\_transformers/tests/modeling\_transfo\_xl\_test.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvdGVzdHMvbW9kZWxpbmdfdHJhbnNmb194bF90ZXN0LnB5) | `94.33% <100%> (+0.1%)` | :arrow_up: |
| [pytorch\_transformers/modeling\_xlm.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvbW9kZWxpbmdfeGxtLnB5) | `86.48% <100%> (+0.3%)` | :arrow_up: |
| [pytorch\_transformers/modeling\_bert.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvbW9kZWxpbmdfYmVydC5weQ==) | `87.69% <100%> (+0.17%)` | :arrow_up: |
| [pytorch\_transformers/tests/modeling\_gpt2\_test.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvdGVzdHMvbW9kZWxpbmdfZ3B0Ml90ZXN0LnB5) | `84.21% <66.66%> (-3.29%)` | :arrow_down: |
| [pytorch\_transformers/tests/modeling\_openai\_test.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvdGVzdHMvbW9kZWxpbmdfb3BlbmFpX3Rlc3QucHk=) | `84.21% <66.66%> (-0.79%)` | :arrow_down: |
| [pytorch\_transformers/tests/modeling\_xlm\_test.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvdGVzdHMvbW9kZWxpbmdfeGxtX3Rlc3QucHk=) | `72.13% <75%> (ø)` | :arrow_up: |
| [pytorch\_transformers/modeling\_gpt2.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvbW9kZWxpbmdfZ3B0Mi5weQ==) | `75.62% <75%> (-5.39%)` | :arrow_down: |
| [pytorch\_transformers/modeling\_transfo\_xl.py](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree#diff-cHl0b3JjaF90cmFuc2Zvcm1lcnMvbW9kZWxpbmdfdHJhbnNmb194bC5weQ==) | `57.32% <76.92%> (+0.32%)` | :arrow_up: |
| ... and [14 more](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781?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/pytorch-pretrained-BERT/pull/781?src=pr&el=footer). Last update [50e62a4...2918b7d](https://codecov.io/gh/huggingface/pytorch-pretrained-BERT/pull/781?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).