code: def first_step(self, beam, expected_beam_scores, expected_len_pen):
      # no EOS's yet
      self.assertFalse(
          any([any(subbeam) for subbeam in beam.is_finished_list])
      )
      scores_1 = torch.log_softmax(
          torch.tensor(
              [
                  [0, 0, 0, 0.3, 0, 0.51, 0.2, 0],
                  [0, 0, 1.5, 0, 0, 0, 0, 0],
                  [0, 0, 0, 0, 0.49, 0.48, 0, 0],
                  [0, 0, 0, 0.2, 0.2, 0.2, 0.2, 0.2],
                  [0, 0, 0, 0.2, 0.2, 0.2, 0.2, 0.2],
              ]
          ),
          dim=1,
      )
      scores_1 = scores_1.repeat(self.BATCH_SZ, 1)
  
      beam.advance(deepcopy(scores_1), self.random_attn())
  
      new_scores = scores_1 + 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_1 = torch.div(
          unreduced_preds, self.N_WORDS, rounding_mode="trunc"
      )
      # [5, 3, 2, 6, 0], so beam 2 predicts EOS!
      expected_preds_1 = (
          unreduced_preds - expected_bptr_1 * 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_1))
      self.assertTrue(beam.current_backptr.equal(expected_bptr_1))
      self.assertEqual(
          [any(subbeam) for subbeam in beam.is_finished_list].count(
              True
          ),
          self.BATCH_SZ,
      )
      self.assertTrue(
          all([subbeam[2] for subbeam in beam.is_finished_list])
      )  # beam 2 finished
      beam.topk_log_probs.masked_fill_(
          torch.tensor(beam.is_finished_list), -1e10
      )
      beam.update_finished()
      self.assertFalse(
          any([top_beam[0] for top_beam in beam.is_finished_list])
      )
      self.assertFalse(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 3 for calling the TestBeamSearchAgainstReferenceCase obj's underlying member method code with example usage: obj.first_step(beam, expected_beam_scores, expected_len_pen) and returns: expected_beam_scores