tf add resize_token_embeddings method
Author: dzorlu
Pull request: yes

Introduces the `resize_token_embeddings` method for TF models (with the exception of `Transformer-XL`).

My first commit! Thank you for the awesome library.

I often have found myself in need to extend the embeddings vectors to accommodate auxiliary data, it seems that TF models don't have the functionality. Size of the embeddings layer can be changed like following:

```
SIZE = 50000
# T5 Generator
MODEL_NAME = 't5-small'
model2 = TFT5ForConditionalGeneration.from_pretrained(MODEL_NAME)
emb1 = model2.get_input_embeddings()
emb2 = model2.resize_token_embeddings(SIZE)
assert emb2.weight.shape[0] == SIZE
np.allclose(emb1.weight[:10].numpy(), emb2.weight[:10].numpy())

# BERT
model = TFBertForSequenceClassification.from_pretrained('bert-base-cased')
emb1 = model.get_input_embeddings()
emb2 = model.resize_token_embeddings(SIZE)
assert emb2.word_embeddings.shape[0] == SIZE
np.allclose(emb1.word_embeddings[:10].numpy(), emb2.word_embeddings[:10].numpy())
```

- [x] BERT
- [x] GPT
- [x] GPT-2
- [ ] Transformer-XL
- [x] XLNet
- [x] XLM
- [x] RoBERTa
- [x] DistilBERT
- [x] CTRL
- [x] CamemBERT
- [x] ALBERT
- [x] T5
- [x] XLM-RoBERTa
- [x] FlauBERT
- [x] ELECTRA




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

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

```diff
@@            Coverage Diff             @@
##           master    #4351      +/-   ##
==========================================
+ Coverage   76.80%   76.86%   +0.05%     
==========================================
  Files         128      128              
  Lines       21602    21669      +67     
==========================================
+ Hits        16591    16655      +64     
- Misses       5011     5014       +3     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/4351?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9yb2JlcnRhLnB5) | `74.48% <ø> (-0.26%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_t5.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl90NS5weQ==) | `91.26% <13.33%> (-2.46%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_ctrl.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9jdHJsLnB5) | `97.61% <33.33%> (-0.78%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `82.43% <33.33%> (-0.45%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `90.33% <33.33%> (-0.96%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9ncHQyLnB5) | `94.68% <33.33%> (-0.64%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9vcGVuYWkucHk=) | `94.87% <33.33%> (-0.71%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_xlm.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl94bG0ucHk=) | `75.54% <33.33%> (-0.31%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl94bG5ldC5weQ==) | `80.03% <33.33%> (-0.27%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_albert.py](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9hbGJlcnQucHk=) | `75.11% <50.00%> (-0.23%)` | :arrow_down: |
| ... and [7 more](https://codecov.io/gh/huggingface/transformers/pull/4351/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/huggingface/transformers/pull/4351?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/4351?src=pr&el=footer). Last update [e8db8b8...8dc8f96](https://codecov.io/gh/huggingface/transformers/pull/4351?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


hi team- i know you guys are busy. do you mind taking a look when you have a chance & let me know w/ any comments? thanks!

Hi- Thanks for the feedback. Sure, I can.

Sorry context switching is difficult at times :) I remember that `TFBertMainLayer` implementation was slightly different because it does not inherit from `TFPreTrainedModel` as T5 does. So it requires its own `_get_resized_embeddings` and test modules. But to the extent other architectures are similar to `T5`, it shouldn't be a problem. 

Is there a source of truth for all the TF architectures implemented? Is https://github.com/huggingface/transformers#model-architectures kept up to date?

Deniz


Yes, that list is kept up to date!

@LysandreJik please take a look. thanks!

This looks good! Pinging @jplu for review as he's the TF master around here.

Thank you @jplu @LysandreJik ! Looking forward to contributing more.