TypeError: forward() got an unexpected keyword argument 'label' in main tutorial
Author: monk1337
Pull request: no

I am following the instructions provided in https://huggingface.co/transformers/training.html and trying to use PyTorch API for Fine-tuning, here is the error I am getting


```
from datasets import load_dataset
from transformers import AutoTokenizer
from torch.utils.data import DataLoader
from transformers import AutoModelForSequenceClassification


from transformers import get_scheduler
from transformers import AdamW
import torch
from tqdm.auto import tqdm




raw_datasets = load_dataset("imdb")
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")

def tokenize_function(examples):
    return tokenizer(examples["text"], padding="max_length", truncation=True)

tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)
tokenized_datasets = tokenized_datasets.remove_columns(["text"])
tokenized_datasets.set_format("torch")

small_train_dataset = tokenized_datasets["train"].shuffle(seed=42).select(range(1000))
small_eval_dataset = tokenized_datasets["test"].shuffle(seed=42).select(range(1000))
train_dataloader = DataLoader(small_train_dataset, shuffle=True, batch_size=8)
eval_dataloader = DataLoader(small_eval_dataset, batch_size=8)
model = AutoModelForSequenceClassification.from_pretrained("bert-base-cased", num_labels=2)




optimizer = AdamW(model.parameters(), lr=5e-5)


num_epochs = 3
num_training_steps = num_epochs * len(train_dataloader)
lr_scheduler = get_scheduler(
    "linear",
    optimizer=optimizer,
    num_warmup_steps=0,
    num_training_steps=num_training_steps
)

device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
model.to(device)


progress_bar = tqdm(range(num_training_steps))

model.train()
for epoch in range(num_epochs):
    for batch in train_dataloader:
        batch = {k: v.to(device) for k, v in batch.items()}
        outputs = model(**batch)
        loss = outputs.loss
        loss.backward()

        optimizer.step()
        lr_scheduler.step()
        optimizer.zero_grad()
        progress_bar.update(1)
```


Error 


```
TypeError                                 Traceback (most recent call last)
<ipython-input-74-79930d537f14> in <module>()
     54     for batch in train_dataloader:
     55         batch = {k: v.to(device) for k, v in batch.items()}
---> 56         outputs = model(**batch)
     57         loss = outputs.loss
     58         loss.backward()

/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)
   1049         if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
   1050                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1051             return forward_call(*input, **kwargs)
   1052         # Do not call functions when jit is used
   1053         full_backward_hooks, non_full_backward_hooks = [], []

TypeError: forward() got an unexpected keyword argument 'label'
```

Comments:
You missed a line in the tutorial:

```python
tokenized_datasets = tokenized_datasets.remove_columns(["text"])  # this you have
tokenized_datasets = tokenized_datasets.rename_column("label", "labels")  # MISSED
tokenized_datasets.set_format("torch")  # this you have
```

Model expects a column called `labels` not `label` so that is why it complains.

I had to restart everything from scratch and it worked. Before that, I tried renaming the label to labels but got this error :



```
KeyError                                  Traceback (most recent call last)
<ipython-input-5-c7230e7411f6> in <module>()
     27 tokenized_datasets.set_format("torch")  # this you have
     28 
---> 29 train_dataset = tokenized_datasets["train"].shuffle(seed=42).select(range(1000))
     30 eval_dataset = tokenized_datasets["test"].shuffle(seed=42).select(range(1000))
     31 train_dataloader = DataLoader(train_dataset, shuffle=True, batch_size=8)

6 frames
/usr/local/lib/python3.7/dist-packages/datasets/info.py in __post_init__(self)
    177                 for idx, template in enumerate(self.task_templates):
    178                     if isinstance(template, TextClassification):
--> 179                         labels = self.features[template.label_column].names
    180                         self.task_templates[idx] = TextClassification(
    181                             text_column=template.text_column, label_column=template.label_column, labels=labels

KeyError: 'label'
```

> You missed a line in the tutorial:
> 
> tokenized_datasets = tokenized_datasets.remove_columns(["text"])  # this you have
> tokenized_datasets = tokenized_datasets.rename_column("label", "labels")  # MISSED
> tokenized_datasets.set_format("torch")  # this you have
> Model expects a column called `labels` not `label` so that is why it complains.

and how could we know what dataset format a pretrained model is expecting in general?