T5 support for text classification demo code
Author: Yu-Shi
Pull request: no

## Environment info
- `transformers` version: 4.10.2
- Platform: Linux-4.4.0-210-generic-x86_64-with-debian-stretch-sid
- Python version: 3.7.0
- PyTorch version (GPU?): 1.9.0+cu102 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No

### Who can help

@sgugger, @patil-suraj, @patrickvonplaten 

## Information

Model I am using (Bert, XLNet ...): T5

The problem arises when using:
* [x] the official example scripts: `examples/pytorch/text-classification/run_glue.py`
* [ ] my own modified scripts: (give details below)

The tasks I am working on is:
* [x] an official GLUE/SQUaD task: GLUE
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

Just run https://github.com/huggingface/transformers/blob/master/examples/pytorch/text-classification/run_glue.py and set the model to `t5-base`, it produces the following output:

```
raceback (most recent call last):
  File "run_glue.py", line 566, in <module>
    main()
  File "run_glue.py", line 336, in main
    use_auth_token=True if model_args.use_auth_token else None,
  File "/home2/yushi/hf_examples/.venv/lib/python3.7/site-packages/transformers/models/auto/auto_factory.py", line 390, in from_pretrained
    f"Unrecognized configuration class {config.__class__} for this kind of AutoModel: {cls.__name__}.\n"
ValueError: Unrecognized configuration class <class 'transformers.models.t5.configuration_t5.T5Config'> for this kind of AutoModel: AutoModelForSequenceClassification.
Model type should be one of LayoutLMv2Config, RemBertConfig, CanineConfig, RoFormerConfig, BigBirdPegasusConfig, GPTNeoConfig, BigBirdConfig, ConvBertConfig, LEDConfig, IBertConfig, MobileBertConfig, DistilBertConfig, AlbertConfig, CamembertConfig, XLMRobertaConfig, MBartConfig, MegatronBertConfig, MPNetConfig, BartConfig, ReformerConfig, LongformerConfig, RobertaConfig, DebertaV2Config, DebertaConfig, FlaubertConfig, SqueezeBertConfig, BertConfig, OpenAIGPTConfig, GPT2Config, TransfoXLConfig, XLNetConfig, XLMConfig, CTRLConfig, ElectraConfig, FunnelConfig, LayoutLMConfig, TapasConfig.
```

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

It seems that the demo code doesn't support T5. Could you please add T5 support? Thank you!

## Expected behavior

Run successfully


Comments:
The T5 model is not suitable for text classification, as it's a sequence to sequence model. This why there is no version of that model with a classification head, and why the text classification head then fails.

Hi @sgugger, the T5 **is** suitable for text classification, according to the T5 paper. This is performed by assigning a label word for each class and doing generation. 

For example, to classify a sentence from SST2, the input is converted to:

```
sst2 sentence: it confirms fincher ’s status as a film maker who artfully bends technical know-how to the service of psychological insight .
```

The model is trained to generate "positive" for target 1, according to the Appendix D of the paper.

It has become a trend to use generative/seq2seq models for classification tasks. I wonder if HuggingFace could possibly build convenient APIs to support this paradigm. 

> Hi @sgugger, the T5 is suitable for text classification, according to the T5 paper. This is performed by assigning a label word for each class and doing generation.

Yes, so this is done by using T5 as a seq2seq model, not by adding a classification head. Therefore, you can't expect the generic text classification example to work with T5. You can however adapt the seqseq scripts to have then do text classification with T5.

@Yu-Shi  You could refer to this [colab](https://colab.research.google.com/github/patil-suraj/exploring-T5/blob/master/t5_fine_tuning.ipynb) to see how to use T5 for classification and then adapt the `run_summarization.py`  script accordingly, i.e you will need to change the pre-processing part to prepare the input text in the required format. and then adjust the metrics.

Technically, we could add a `run_seq2seq_text_classification.py` script to the examples folder, similar to how `run_seq2seq_qa.py` is added by #13432.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md) are likely to be ignored.