code: def _check_results(
      self,
      batch_size: int = 5,
      expected_top_k: np.array = None,
      expected_log_probs: np.array = None,
      beam_search: BeamSearch = None,
      state: Dict[str, torch.Tensor] = None,
      take_step=take_step_with_timestep,
  ) -> None:
      expected_top_k = (
          expected_top_k
          if expected_top_k is not None
          else self.expected_top_k
      )
      expected_log_probs = (
          expected_log_probs
          if expected_log_probs is not None
          else self.expected_log_probs
      )
      state = state or {}
  
      beam_search = beam_search or self.beam_search
      beam_size = beam_search.beam_size
  
      initial_predictions = torch.tensor([0] * batch_size)
      top_k, log_probs = beam_search.search(initial_predictions, state, take_step)  # type: ignore
  
      # top_k should be shape `(batch_size, beam_size, max_predicted_length)`.
      assert list(top_k.size())[:-1] == [batch_size, beam_size]
      np.testing.assert_array_equal(top_k[0].numpy(), expected_top_k)
  
      # log_probs should be shape `(batch_size, beam_size, max_predicted_length)`.
      assert list(log_probs.size()) == [batch_size, beam_size]
      np.testing.assert_allclose(
          log_probs[0].numpy(), expected_log_probs, rtol=1e-6
      )
  
imports: from typing import Dict, Tuple, Union
  import numpy
  import pytest
  import torch
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.testing import AllenNlpTestCase
  from allennlp.nn.beam_search import MultinomialSampler, BeamSearch, TopKSampler, TopPSampler, GumbelSampler, LengthNormalizedSequenceLogProbabilityScorer, RepeatedNGramBlockingConstraint, StepFunctionTypeWithTimestep, StepFunctionTypeNoTimestep
  from allennlp.common.params import Params
  from allennlp.nn.util import min_value_of_dtype
label_desc: Use image node_id 2 for calling the BeamSearchTest obj's underlying member method code with example usage: obj._check_results(batch_size, expected_top_k, expected_log_probs, beam_search, state, take_step) without return types