code: def test_transition_scores_early_stopping(self):
      # This is an aggressive test that makes sure that `beam_search's`
      # transition scores are computed correctly for varying `num_return_sequences`, `num_beams` and `batch_size > 1`
      # 2 x input_ids for "question: How are you? \n context: I had a long day, "
      model_cls = self.framework_dependent_parameters[
          "AutoModelForSeq2SeqLM"
      ]
      create_tensor_fn = self.framework_dependent_parameters[
          "create_tensor_fn"
      ]
      is_pt = not model_cls.__name__.startswith("TF")
  
      input_ids = create_tensor_fn(
          2
          * [
              [
                  822,
                  10,
                  571,
                  33,
                  25,
                  58,
                  2625,
                  10,
                  27,
                  141,
                  3,
                  9,
                  307,
                  239,
                  6,
                  1,
              ]
          ]
      )
      model = model_cls.from_pretrained("t5-small")
      if is_pt:
          model = model.to(torch_device)
          input_ids = input_ids.to(torch_device)
  
      outputs = model.generate(
          input_ids,
          max_length=10,
          return_dict_in_generate=True,
          output_scores=True,
          forced_eos_token_id=model.config.eos_token_id,
          num_beams=4,
          do_sample=False,
          num_return_sequences=3,
          length_penalty=0.0,
      )
  
      transition_scores = model.compute_transition_scores(
          sequences=outputs.sequences,
          scores=outputs.scores,
          beam_indices=outputs.beam_indices,
      )
      if is_pt:
          transition_scores = transition_scores.cpu().numpy()
          outputs.sequences_scores = (
              outputs.sequences_scores.cpu().numpy()
          )
  
      self.assertTrue(
          np.allclose(
              np.sum(transition_scores, axis=-1),
              outputs.sequences_scores,
          )
      )
  
imports: import numpy
  from transformers import AutoTokenizer
  from transformers.testing_utils import slow, torch_device
label_desc: Use image node_id 12 for calling the GenerationIntegrationTestsMixin obj's underlying member method code with example usage: obj.test_transition_scores_early_stopping() without return types