TypeError: BartModel.forward() got an unexpected keyword argument 'labels'
Author: mwnthainarzary
Pull request: no
Labels: name: bug

### System Info

```
TypeError                                 Traceback (most recent call last)

[<ipython-input-37-3435b262f1ae>](https://localhost:8080/#) in <cell line: 0>()
----> 1 trainer.train()

5 frames

[/usr/local/lib/python3.11/dist-packages/torch/nn/modules/module.py](https://localhost:8080/#) in _call_impl(self, *args, **kwargs)
   1745                 or _global_backward_pre_hooks or _global_backward_hooks
   1746                 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1747             return forward_call(*args, **kwargs)
   1748 
   1749         result = None

TypeError: BartModel.forward() got an unexpected keyword argument 'labels'
```
### Who can help?

@ArthurZucker, @muellerzr, @SunMarc 

### Information

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

### Tasks

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

### Reproduction
```python
import torch
import matplotlib.pyplot as plt
from transformers import pipeline
from datasets import Dataset, DatasetDict
from transformers import BartTokenizer, BartModel, TrainingArguments, Trainer, DataCollatorForSeq2Seq
import pandas as pd
# from datasets import Dataset 

df_train = pd.read_csv('../test-set/train.csv')
df_test = pd.read_csv('../test-set/test.csv')
df_val = pd.read_csv('../test-set/valid.csv')

df_train = df_train.dropna()
df_test = df_test.dropna()
df_val = df_val.dropna()

# Convert DataFrames to Hugging Face Datasets
dataset_train = Dataset.from_pandas(df_train)
dataset_test = Dataset.from_pandas(df_test)
dataset_val = Dataset.from_pandas(df_val)

# Create DatasetDict
dataset_dict = DatasetDict({
    'train': dataset_train,
    'test': dataset_test,
    'validation': dataset_val
})


dataset_samsum = dataset_dict

split_train_test_val = [len(dataset_samsum[split]) for split in dataset_samsum]

from transformers import BartTokenizer, BartModel
model_ckpt = "facebook/bart-large"
tokenizer = BartTokenizer.from_pretrained('facebook/bart-large')
model = BartModel.from_pretrained('facebook/bart-large')


d_len = [len(tokenizer.encode(s)) for s in dataset_samsum["train"]["judgement"]]
s_len = [len(tokenizer.encode(s)) for s in dataset_samsum["train"]["summary"]]


def convert_examples_to_features(example_batch):
    input_encodings = tokenizer(example_batch["judgement"], max_length=1024, truncation=True)
    
    #Using target_tokenizer for summaries 
    with tokenizer.as_target_tokenizer():
        target_encodings = tokenizer(example_batch["summary"], max_length=128, truncation=True)
        
    return {
        "input_ids": input_encodings["input_ids"], 
        "attention_mask": input_encodings["attention_mask"],  
        "labels": target_encodings["input_ids"]
    }

dataset_samsum_pt = dataset_samsum.map(convert_examples_to_features, batched=True)

columns = ["input_ids", "labels", "attention_mask"]
dataset_samsum_pt.set_format(type="torch", columns=columns)

# Collator for Handling length imbalances and attention masks 
seq2seq_data_collator = DataCollatorForSeq2Seq(tokenizer, model=model)


training_args = TrainingArguments( output_dir="bart-large-bodosum",
                                 num_train_epochs=1,
                                 warmup_steps=500,
                                 per_device_train_batch_size=1,
                                 per_gpu_eval_batch_size=1,
                                 weight_decay=0.01,
                                 logging_steps=10, 
                                 evaluation_strategy='steps', 
                                 eval_steps=500,
                                 save_steps=1e6,
                                 gradient_accumulation_steps=16,
                                )

trainer = Trainer(model=model, args=training_args, tokenizer=tokenizer, data_collator=seq2seq_data_collator,
                 train_dataset=dataset_samsum_pt["train"],
                 eval_dataset=dataset_samsum_pt["validation"])

trainer.train()
```
### Expected behavior

I am trying to train facebook/bart-large model for summarization task. But when I try to run trainer.train() then I encountered this issue. Please help me to solve this issue

Comments:
`BartModel` does not support passing labels 😉 you should use `BartForConditionalGeneration`

Thanks