code: def test_beam_search(self):
      vocab = text_utils.VocabFromText(self.VOCAB_EXAMPLE_SENTENCES)
      model_config = self.config.model_config.butd
      model = TestDecoderModel(model_config, vocab)
      model.build()
      model.eval()
  
      expected_tokens = {
          1: [1.0, 23.0, 1.0, 24.0, 29.0, 37.0, 40.0, 17.0, 29.0, 2.0],
          2: [1.0, 0.0, 8.0, 1.0, 28.0, 25.0, 2.0],
          8: [1.0, 34.0, 1.0, 13.0, 1.0, 2.0],
          16: [1.0, 25.0, 18.0, 2.0],
      }
  
      for batch_size in [1, 2, 8, 16]:
          samples = []
          for _ in range(batch_size):
              sample = Sample()
              sample.dataset_name = "coco"
              sample.dataset_type = "test"
              sample.image_feature_0 = torch.randn(100, 2048)
              sample.answers = torch.zeros((5, 10), dtype=torch.long)
              samples.append(sample)
  
          sample_list = SampleList(samples)
          tokens = model(sample_list)["captions"]
          self.assertEqual(
              np.trim_zeros(tokens[0].tolist()),
              expected_tokens[batch_size],
          )
  
imports: import os
  import unittest
  import mmf.utils.text
  import numpy
  import torch
  from mmf.common.registry import registry
  from mmf.common.sample import Sample, SampleList
  from mmf.utils.configuration import Configuration
  from mmf.utils.env import setup_imports
  from mmf.utils.general import get_mmf_root
  from tests.test_utils import dummy_args
  from tests.utils.test_model import TestDecoderModel
label_desc: Use image node_id 2 for calling the TestUtilsTextBeamSearch obj's underlying member method code with example usage: obj.test_beam_search() without return types