[WIP] lightning_base: support --lr_scheduler with multiple possibilities
Author: stas00
Pull request: yes

This is step 1 to implement https://github.com/huggingface/transformers/issues/6070

This PR adds support to:

```
python finetune.py [...]  --lr_scheduler=SCHEDULER [...]
```

in lightning_base (so seq2seq examples, etc.)

to get help:

```
python finetune.py [...]  --lr_scheduler=help [...]
```
gives:
```
Available lr_schedulers:
--lr_scheduler=cosine (get_cosine_schedule_with_warmup)
--lr_scheduler=cosine_w_restarts (get_cosine_with_hard_restarts_schedule_with_warmup)
--lr_scheduler=linear (get_linear_schedule_with_warmup)
--lr_scheduler=help (this help)
```
the rest is hopefully obvious.

I'm not sure where to document this new option - I added a note to `seq2seq/README.md`, but it should work for any other module under examples/. That makes me think that in this PR https://github.com/huggingface/transformers/pull/6149 the new options are only documented in `seq2seq/README.md`, but should be usable under other examples - i.e. it's not s2s-specific, but examples/README.md doesn't look like it's going into any details. Thoughts?

I wrote tests inside `seq2seq` too, but it should work anywhere.

@sshleifer



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

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

```diff
@@            Coverage Diff             @@
##           master    #6232      +/-   ##
==========================================
- Coverage   79.47%   78.49%   -0.99%     
==========================================
  Files         146      146              
  Lines       26607    26607              
==========================================
- Hits        21146    20885     -261     
- Misses       5461     5722     +261     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/6232?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_mobilebert.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9tb2JpbGViZXJ0LnB5) | `23.38% <0.00%> (-73.39%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_flaubert.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9mbGF1YmVydC5weQ==) | `24.22% <0.00%> (-63.98%)` | :arrow_down: |
| [src/transformers/tokenization\_xlnet.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25feGxuZXQucHk=) | `90.09% <0.00%> (+23.42%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_gpt2.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9ncHQyLnB5) | `95.32% <0.00%> (+23.67%)` | :arrow_up: |
| [src/transformers/tokenization\_marian.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy90b2tlbml6YXRpb25fbWFyaWFuLnB5) | `93.80% <0.00%> (+25.66%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/6232/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `98.79% <0.00%> (+34.61%)` | :arrow_up: |

------

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


I noticed another thing, `seq2seq/finetune.py`, has a hardcoded:

```
        scheduler = get_linear_schedule_with_warmup(
            self.opt, num_warmup_steps=self.hparams.warmup_steps, num_training_steps=t_total
        )
```

should I switch to using a superclass' `get_lr_scheduler` method that this PR adds instead ?

I haven't checked the other sub-classes - probably needs the same. Or leave that to another PR?

All the requested changes have been addressed. 

Currently we get:

```
finetune.py [...] --lr_scheduler=cosine1
finetune.py: error: argument --lr_scheduler: invalid choice: 'cosine1' (choose from 'cosine', 'cosine_w_restarts', 'linear')
```


```
finetune.py [...] --help
[...]
                   [--learning_rate LEARNING_RATE]
                   [--lr_scheduler {cosine, cosine_w_restarts, linear}]
                   [--weight_decay WEIGHT_DECAY] [--adam_epsilon ADAM_EPSILON]
[...]
```
I used `metavar`  in addition to `choices` to make the output a bit user-friendlier - it'll still be less so once there will be many schedulers on that list - `argparse` doesn't wrap them and doesn't allow multiline `metavar`.

I suppose they are now self-documented. If you want a doc somewhere, please let me know where to do it.