Overflow error: Can't convert negative int to unsigned [finetuning Bart]
Author: matsuobasho
Pull request: no

### System Info

Platform: Windows 10
Device: cpu
Python: 3.9.6
Transformers: 4.35.2
Datasets: 2.15.0
Torch: 2.1.1

### Who can help?

@muellerzr  @pacman100  

### Information

- [ ] The official example scripts
- [X] 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

```python

MAX_OUTPUT_SEQ = 35
BATCH_SIZE = 2
DIR_NAME = './test_dir'
DEVICE = 'cpu'
EPOCHS = 3

def tokenize_function(tok, seq_length, example):
    inp = tok(example['input_seq'], padding=True, truncation=True)
    outp = tok(example['orig_sent'],
               padding="max_length",
               max_length=seq_length)

    res = {
        'input_ids': inp['input_ids'],
        'attention_mask': inp['attention_mask'],
        'decoder_input_ids': outp['input_ids'],
        'labels': outp['input_ids'],
        'decoder_attention_mask': outp['attention_mask']
    }
    return res

checkpoint = "facebook/bart-large"

tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)

# not including the dataset creation here
ds = datasets.Dataset.from_dict({
    "input_seq": input_filtered,
    "orig_sent": orig_sent_filtered
})

data_prepped = ds.train_test_split()

def compute_metrics(eval_preds):
    preds, labels = eval_preds   # shape during debug is 9 x 32
    # In case the model returns more than the prediction logits
    if isinstance(preds, tuple):
        preds = preds[0]

    decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=True)

    # Replace -100s in the labels as we can't decode them
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    # Some simple post-processing
    decoded_preds = [pred.strip() for pred in decoded_preds]
    decoded_labels = [[label.strip()] for label in decoded_labels]

    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
    return {"bleu": result["score"]}

data_tokenized = data_prepped.map(
    partial(funcs.tokenize_function, tokenizer, MAX_OUTPUT_SEQ),
    batched=True,
    batch_size=BATCH_SIZE,
    remove_columns=['input_seq', 'orig_sent'])

training_args = Seq2SeqTrainingArguments(
    output_dir=DIR_NAME,
    evaluation_strategy='epoch',
    logging_strategy='epoch',
    gradient_checkpointing=True,
    num_train_epochs=EPOCHS,
    predict_with_generate = True,
    generation_max_length=MAX_OUTPUT_SEQ,
    per_device_train_batch_size=BATCH_SIZE)

trainer = Seq2SeqTrainer(model,
                    training_args,
                    train_dataset=data_tokenized["train"],
                    eval_dataset=data_tokenized["test"],
                    data_collator=data_collator,
                    compute_metrics = compute_metrics,
                    tokenizer=tokenizer)

trainer.train()
```

Error I get:
```
OverflowError                             Traceback (most recent call last)
c:\Users\Alf\project\notebooks\test_w_compute_metrics.ipynb Cell 8 line 2
      1 training_args = Seq2SeqTrainingArguments(
      2     output_dir=DIR_NAME,
      3     #fp16=True,
   (...)
      9     generation_max_length=MAX_OUTPUT_SEQ,
     10     per_device_train_batch_size=BATCH_SIZE)
     12 trainer = Seq2SeqTrainer(model,
     13                     training_args,
     14                     train_dataset=data_tokenized["train"],
   (...)
     17                     compute_metrics = compute_metrics,
     18                     tokenizer=tokenizer)
---> 20 trainer.train()

File c:\Users\Alf\.virtualenvs\env_name\site-packages\transformers\trainer.py:1555, in Trainer.train(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)
   1553         hf_hub_utils.enable_progress_bars()
   1554 else:
-> 1555     return inner_training_loop(
   1556         args=args,
   1557         resume_from_checkpoint=resume_from_checkpoint,
   1558         trial=trial,
   1559         ignore_keys_for_eval=ignore_keys_for_eval,
...
    630     else self.clean_up_tokenization_spaces
    631 )
    632 if clean_up_tokenization_spaces:

OverflowError: can't convert negative int to unsigned
```
Important to note that there is no error if I comment out the `generation_max_length` argument in `Seq2SeqTrainingArguments`.  
Also note that this is the same error as in [this ](https://github.com/huggingface/transformers/issues/7517)closed issue from 3 years ago, but my datasets is updated.


### Expected behavior

Trainer runs without errors.  

Comments:
Not a bug, merely has to do with `compute_metrics` not having a step to convert the -100 padded label values to `pad_token_id`.  Adding that line gets rid of the error.
```
def compute_metrics(eval_preds):
    preds, labels = eval_preds  
    if isinstance(preds, tuple):
        preds = preds[0]

    preds = np.where(preds != -100, preds, tokenizer.pad_token_id)

    decoded_preds = tokenizer.batch_decode(preds, skip_special_tokens=True)

    # Replace -100s in the labels as we can't decode them
    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)


    decoded_preds = [pred.strip() for pred in decoded_preds]
    decoded_labels = [[label.strip()] for label in decoded_labels]

    result = metric.compute(predictions=decoded_preds, references=decoded_labels)
    return {"bleu": result["score"]}
```  

Closing issue