def _seq2seq_metrics(pred, tokenizer):
    """
    Compute sequence-to-sequence metrics for predictions and labels.

    Args:
        pred (tuple): A tuple containing predictions and labels.
                      Predictions and labels are expected to be token IDs.
        tokenizer (PreTrainedTokenizer): The tokenizer used for decoding the predictions and labels.

    Returns:
        dict: A dictionary containing the computed ROUGE metrics and the average length of the generated sequences.
              The keys are the metric names and the values are the corresponding scores rounded to four decimal places.
    """
    predictions, labels = pred
    decoded_preds = tokenizer.batch_decode(predictions, skip_special_tokens=True)

    labels = np.where(labels != -100, labels, tokenizer.pad_token_id)
    decoded_labels = tokenizer.batch_decode(labels, skip_special_tokens=True)

    decoded_preds = ["\n".join(nltk.sent_tokenize(pred.strip())) for pred in decoded_preds]
    decoded_labels = ["\n".join(nltk.sent_tokenize(label.strip())) for label in decoded_labels]

    result = ROUGE_METRIC.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=True)
    result = {key: value * 100 for key, value in result.items()}

    prediction_lens = [np.count_nonzero(pred != tokenizer.pad_token_id) for pred in predictions]
    result["gen_len"] = np.mean(prediction_lens)

    return {k: round(v, 4) for k, v in result.items()}

    Compute sequence-to-sequence metrics for predictions and labels.

    Args:
        pred (tuple): A tuple containing predictions and labels.
                      Predictions and labels are expected to be token IDs.
        tokenizer (PreTrainedTokenizer): The tokenizer used for decoding the predictions and labels.

    Returns:
        dict: A dictionary containing the computed ROUGE metrics and the average length of the generated sequences.
              The keys are the metric names and the values are the corresponding scores rounded to four decimal places.
    
src/autotrain/trainers/seq2seq/utils.py