code: def third_step(self, beam, expected_beam_scores, expected_len_pen):
      # assumes beam 0 finished on last step
      scores_3 = torch.log_softmax(
          torch.tensor(
              [
                  [
                      0,
                      0,
                      10000,
                      0,
                      5000,
                      0.51,
                      0.2,
                      0,
                  ],  # beam 0 shouldn't cont
                  [0, 0, 0, 0, 0, 0, 0, 0],
                  [0, 0, 10000, 0, 0, 5000, 0, 0],
                  [
                      0,
                      0,
                      50,
                      0.2,
                      0.2,
                      0.2,
                      0.2,
                      0.2,
                  ],  # beam 3 -> beam 1 should die
                  [0, 0, 50, 0, 0.2, 0.2, 0.2, 0.2],
              ]
          ),
          dim=1,
      )
      scores_3 = scores_3.repeat(self.BATCH_SZ, 1)
  
      beam.advance(deepcopy(scores_3), self.random_attn())
  
      expected_beam_scores[:, 0 :: self.BEAM_SZ] = self.DEAD_SCORE
      new_scores = scores_3 + expected_beam_scores.view(-1).unsqueeze(1)
      expected_beam_scores, unreduced_preds = new_scores.view(
          self.BATCH_SZ, self.BEAM_SZ * self.N_WORDS
      ).topk(self.BEAM_SZ, -1)
      expected_bptr_3 = torch.div(
          unreduced_preds, self.N_WORDS, rounding_mode="trunc"
      )
      # [5, 2, 6, 1, 0] repeat self.BATCH_SZ, so beam 1 predicts EOS!
      expected_preds_3 = (
          unreduced_preds - expected_bptr_3 * self.N_WORDS
      )
      self.assertTrue(
          beam.topk_log_probs.allclose(expected_beam_scores)
      )
      self.assertTrue(
          beam.topk_scores.allclose(
              expected_beam_scores / expected_len_pen
          )
      )
      self.assertTrue(beam.topk_ids.equal(expected_preds_3))
      self.assertTrue(beam.current_backptr.equal(expected_bptr_3))
      # we finish 3 hyps per example in this step
      self.assertEqual(
          sum(
              [subbeam.count(True) for subbeam in beam.is_finished_list]
          ),
          self.BATCH_SZ * 3,
      )
      # new beam 1 is old beam 3
      self.assertTrue(expected_bptr_3[:, 1].eq(3).all())
      beam.topk_log_probs.masked_fill_(
          torch.tensor(beam.is_finished_list), -1e10
      )
      beam.update_finished()
      self.assertTrue(
          all([top_beam[0] for top_beam in beam.is_finished_list])
      )
      self.assertTrue(beam.done)
      return expected_beam_scores
  
imports: import unittest
  from onmt.translate.beam_search import BeamSearch, GNMTGlobalScorer
  from onmt.translate.beam_search import BeamSearchLM
  from copy import deepcopy
  import torch
label_desc: Use image node_id 5 for calling the TestBeamSearchAgainstReferenceCase obj's underlying member method code with example usage: obj.third_step(beam, expected_beam_scores, expected_len_pen) and returns: expected_beam_scores