code: def test_get_finished_states(self):
      finished_states = self.trainer._get_finished_states(
          self.initial_state, self.decoder_step
      )
      state_info = [
          (state.action_history[0], state.score[0].item())
          for state in finished_states
      ]
      # There will be exactly five finished states with the following paths. Each score is the
      # negative of one less than the number of elements in the action history.
      assert len(finished_states) == 5
      assert ([0, 2, 4], -2) in state_info
      assert ([0, 1, 2, 4], -3) in state_info
      assert ([0, 1, 3, 4], -3) in state_info
      assert ([0, 2, 3, 4], -3) in state_info
      assert ([0, 1, 2, 3, 4], -4) in state_info
  
file_path: magnitude/pymagnitude/third_party/allennlp/tests/nn/decoding/decoder_trainers/expected_risk_minimization_test.py
imports: from __future__ import division
  from __future__ import absolute_import
  import torch
  import numpy
  from numpy.testing import assert_almost_equal
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.nn.decoding.decoder_trainers import ExpectedRiskMinimization
  from ..simple_transition_system import SimpleDecoderState, SimpleDecoderStep
label_desc: Use image node_id 2 for calling the TestExpectedRiskMinimization obj's underlying member method code with example usage: obj.test_get_finished_states() without return types