Fine tunning error in /models/t5/modeling_t5.py
Author: ZHM-Sesame
Pull request: no
Labels: name: bug

### System Info

```shell
Keeps getting this error:

"ValueError: not enough values to unpack (expected 2, got 1)


Traceback (most recent call last):
File "run_glue_t5.py", line 591, in <module>
main()
File "run_glue_t5.py", line 509, in main
train_result = trainer.train(resume_from_checkpoint=checkpoint)
File "/opt/conda/lib/python3.8/site-packages/transformers/trainer.py", line 1400, in train
tr_loss_step = self.training_step(model, inputs)
  File "/opt/conda/lib/python3.8/site-packages/transformers/trainer.py", line 1984, in training_step
loss = self.compute_loss(model, inputs)
  File "/opt/conda/lib/python3.8/site-packages/transformers/trainer.py", line 2016, in compute_loss
outputs = model(**inputs)
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1149, in _call_impl
result = forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/transformers/models/t5/modeling_t5.py", line 1635, in forward
    decoder_outputs = self.decoder(
  File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1149, in _call_impl
    result = forward_call(*input, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/transformers/models/t5/modeling_t5.py", line 933, in forward
    batch_size, seq_length = input_shape
ValueError: not enough values to unpack (expected 2, got 1)
0%|          | 0/3796 [00:03<?, ?it/s]
2022-05-11 19:21:02,332 sagemaker-training-toolkit ERROR    Reporting training FAILURE
2022-05-11 19:21:02,333 sagemaker-training-toolkit ERROR    ExecuteUserScriptError:
ExitCode 1
ErrorMessage "ValueError: not enough values to unpack (expected 2, got 1)
 0%|          | 0/3796 [00:03<?, ?it/s]"
Command "/opt/conda/bin/python3.8 run_glue_t5.py --do_train True --learning_rate 2e-05 --max_seq_length 128 --model_name_or_path t5-small --num_train_epochs 1 --output_dir /opt/ml/model/t5_small --per_device_train_batch_size 64 --train_file /opt/ml/input/data/train/train.csv --validation_file /opt/ml/input/data/val/val.csv"
2022-05-11 19:21:02,333 sagemaker-training-toolkit ERROR    Encountered exit_code 1
```


### Who can help?

_No response_

### Information

- [x] The official example scripts
- [ ] My own modified scripts

### Tasks

- [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

for using t5 series, like 't5-small', the model definition in run_glue.py should be:

model = MT5ForConditionalGeneration.from_pretrained(...)
instead of 
model = AutoModelForSequenceClassification.from_pretrained(...) #this line couldn't work

after change the above line, still coudln't work for the "ValueError: not enough values to unpack (expected 2, got 1)" from the linke : `batch_size, seq_length = input_shape` in modeling_t5.py.


```
import sagemaker
from sagemaker.huggingface import HuggingFace

hyperparameters = {
    'model_name_or_path':'t5-small',
    'output_dir':'/opt/ml/model/t5_small',
    'max_seq_length':128,
    'per_device_train_batch_size' : 64,
    'learning_rate' : 2e-5,
    'num_train_epochs': 1,
    'do_train': True,
    'train_file': '/opt/ml/input/data/train/train.csv',
    'validation_file': '/opt/ml/input/data/val/val.csv',
}

git_config = {'repo': 'https://github.com/huggingface/transformers.git','branch': 'v4.17.0'}

huggingface_estimator = HuggingFace(
    entry_point='run_glue.py',
    source_dir='./examples/pytorch/text-classification',
    instance_type='ml.g5.xlarge',
    instance_count=1,
    role=role,
    it_config=git_config,
    transformers_version='4.17.0',
    pytorch_version='1.10.2',
    py_version='py38',
    hyperparameters = hyperparameters
)
```


### Expected behavior

```shell
start trainning
```


Comments:
Hi,

The `run_glue.py` script is only meant to work out-of-the-box for encoder-only Transformers, such as BERT, RoBERTa, DistilBERT, DeBERTa, etc.

T5 is an encoder-decoder model, and would require several changes to the script.

> 
I see. 

Thank you.