Fix AdamW import error for <1.2
Author: BramVanroy
Pull request: yes

closes #1585 

Comments:
# [Codecov](https://codecov.io/gh/huggingface/transformers/pull/1593?src=pr&el=h1) Report
> Merging [#1593](https://codecov.io/gh/huggingface/transformers/pull/1593?src=pr&el=desc) into [master](https://codecov.io/gh/huggingface/transformers/commit/702f589848baba97ea4897aa3f0bb937e1ec3bcf?src=pr&el=desc) will **decrease** coverage by `0.77%`.
> The diff coverage is `82.23%`.

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

```diff
@@            Coverage Diff             @@
##           master    #1593      +/-   ##
==========================================
- Coverage   84.73%   83.95%   -0.78%     
==========================================
  Files          84       94      +10     
  Lines       12573    13951    +1378     
==========================================
+ Hits        10654    11713    +1059     
- Misses       1919     2238     +319
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/1593?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [transformers/modeling\_tf\_transfo\_xl.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX3RyYW5zZm9feGwucHk=) | `92.21% <ø> (+0.97%)` | :arrow_up: |
| [transformers/modeling\_tf\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX2JlcnQucHk=) | `96.6% <ø> (+0.89%)` | :arrow_up: |
| [transformers/modeling\_tf\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX2dwdDIucHk=) | `94.79% <ø> (+1.31%)` | :arrow_up: |
| [transformers/tokenization\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rva2VuaXphdGlvbl9ncHQyLnB5) | `96.72% <ø> (ø)` | :arrow_up: |
| [transformers/configuration\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2NvbmZpZ3VyYXRpb25fZ3B0Mi5weQ==) | `88.63% <ø> (ø)` | :arrow_up: |
| [transformers/configuration\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2NvbmZpZ3VyYXRpb25fcm9iZXJ0YS5weQ==) | `100% <ø> (ø)` | :arrow_up: |
| [transformers/configuration\_bert.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL2NvbmZpZ3VyYXRpb25fYmVydC5weQ==) | `87.09% <ø> (ø)` | :arrow_up: |
| [transformers/modeling\_tf\_openai.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX29wZW5haS5weQ==) | `96.04% <ø> (+1.43%)` | :arrow_up: |
| [transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL21vZGVsaW5nX3RmX2Rpc3RpbGJlcnQucHk=) | `98.59% <ø> (+1.98%)` | :arrow_up: |
| [transformers/tests/modeling\_tf\_gpt2\_test.py](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree#diff-dHJhbnNmb3JtZXJzL3Rlc3RzL21vZGVsaW5nX3RmX2dwdDJfdGVzdC5weQ==) | `94.73% <0%> (ø)` | :arrow_up: |
| ... and [79 more](https://codecov.io/gh/huggingface/transformers/pull/1593/diff?src=pr&el=tree-more) | |

------

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


I just realized that it's better to try to import AdamW in optimization, and if not available define the custom AdamW class.