result = rouge.compute(predictions=decoded_preds, references=decoded_labels, use_stemmer=True)
     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()}

Your compute_metrics function is ready to go now, and you'll return to it when you setup your training.
Train