code: def test_bleu_scores(self, pair, min_bleu_score):
      # note: this test is not testing the best performance since it only evals a small batch
      # but it should be enough to detect a regression in the output quality
      mname = f"facebook/wmt19-{pair}"
      tokenizer = self.get_tokenizer(mname)
      model = self.get_model(mname)
  
      src_sentences = bleu_data[pair]["src"]
      tgt_sentences = bleu_data[pair]["tgt"]
  
      batch = tokenizer(
          src_sentences,
          return_tensors="pt",
          truncation=True,
          padding="longest",
      ).to(torch_device)
      outputs = model.generate(
          input_ids=batch.input_ids,
          num_beams=8,
      )
      decoded_sentences = tokenizer.batch_decode(
          outputs,
          skip_special_tokens=True,
          clean_up_tokenization_spaces=False,
      )
      scores = calculate_bleu(decoded_sentences, tgt_sentences)
      print(scores)
      self.assertGreaterEqual(scores["bleu"], min_bleu_score)
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/examples/legacy/seq2seq/old_test_fsmt_bleu_score.py
imports: import io
  import json
  import unittest
  from parameterized import parameterized
  from transformers import FSMTForConditionalGeneration, FSMTTokenizer
  from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device
  from utils import calculate_bleu
label_desc: Use image node_id 3 for calling the ModelEvalTester obj's underlying member method code with example usage: obj.test_bleu_scores(pair, min_bleu_score) without return types