[Fix] text-classification PL example
Author: bhashithe
Pull request: yes
Labels: name: Examples

The text-classification example needed to have several edits to get it to working. The main one was that the hparams are loaded as a dict instead of a Namespace object from the checkpoint so this needed to be fixed with recasting the hparams to a Namespace object.

Though this is not the ideal solution, it works for now.

I also have some other fixes such as gpus argument which needed to be added to the generic arguments list in the `lightning_base.py` and removing the default value for `n_tpu_cores`. And the lr_scheduler was not accessed by the logging callback correctly. These have been all fixed and the example works correctly.

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

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

```diff
@@            Coverage Diff             @@
##           master    #6027      +/-   ##
==========================================
+ Coverage   77.46%   78.50%   +1.04%     
==========================================
  Files         146      146              
  Lines       26243    26243              
==========================================
+ Hits        20330    20603     +273     
+ Misses       5913     5640     -273     
```


| [Impacted Files](https://codecov.io/gh/huggingface/transformers/pull/6027?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/transformers/modeling\_tf\_electra.py](https://codecov.io/gh/huggingface/transformers/pull/6027/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9lbGVjdHJhLnB5) | `26.02% <0.00%> (-69.52%)` | :arrow_down: |
| [src/transformers/modeling\_tf\_roberta.py](https://codecov.io/gh/huggingface/transformers/pull/6027/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9yb2JlcnRhLnB5) | `43.98% <0.00%> (-49.38%)` | :arrow_down: |
| [src/transformers/generation\_tf\_utils.py](https://codecov.io/gh/huggingface/transformers/pull/6027/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9nZW5lcmF0aW9uX3RmX3V0aWxzLnB5) | `86.21% <0.00%> (+1.25%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_distilbert.py](https://codecov.io/gh/huggingface/transformers/pull/6027/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9kaXN0aWxiZXJ0LnB5) | `98.79% <0.00%> (+33.89%)` | :arrow_up: |
| [src/transformers/modeling\_tf\_mobilebert.py](https://codecov.io/gh/huggingface/transformers/pull/6027/diff?src=pr&el=tree#diff-c3JjL3RyYW5zZm9ybWVycy9tb2RlbGluZ190Zl9tb2JpbGViZXJ0LnB5) | `96.77% <0.00%> (+73.38%)` | :arrow_up: |

------

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


> Why wasn't any of this breaking tests? Is there some test coverage we could add to find these sorts of errors earlier?

 `run_pl_glue.py` isn't being tested. It's not in [`test_examples.py`](https://github.com/huggingface/transformers/blob/master/examples/test_examples.py) and it doesn't have a dedicated test file like some other examples do.

Besides, looking at the output for examples test:

https://circleci.com/gh/huggingface/transformers/64559?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

it's impossible to tell which examples are being run and which aren't. It will only indicate the name on failure. Perhaps at the very least adding a pytest option so that it can announce which tests were run? Submitted PR to do just that: https://github.com/huggingface/transformers/pull/6035


Here is a PR that adds the missing PL glue test: https://github.com/huggingface/transformers/pull/6034 (which obviously fails by CI - a good thing).


@stas00 you can at least see all the files that are run with
`ls examples/**/test*.py`. 

> @stas00 you can at least see all the files that are run with
> `ls examples/**/test*.py`.

you want one dir up as well, so:

`ls -1 examples/test*.py examples/*/test*.py`

but it tells only part of the story, since most info is hidden in `examples/test_examples.py`. e.g. you can't tell pl glue is not being there.



How does this break tf tests? Looks like the model save still has issues with the state_dict its saving.

TF failures are spurious.

Merging this, thanks @bhashithe, @stas00 @laibamehnaz  and everyone else who helped!

The merged https://github.com/huggingface/transformers/pull/6027 broke `examples/seq2seq/test_seq2seq_examples.py::test_finetune_lr_shedulers` - which I think was flagged by failing CI of that PR.

yeah, PL already has `--gpus` - so it conflicts with the one added by 6027. So I will look at how to rework that need in a different way.

Let's continue the discussion here:  https://github.com/huggingface/transformers/issues/6310