code: def test_batch_beam_search(ctc_weight):
      numpy.random.seed(1)
      idim = 10
      args = make_small_arg(ctc_weight=ctc_weight)
      model = e2e_asr.E2E(idim, 5, args)
      torch.manual_seed(1)
      rnnlm = lm_pytorch.ClassifierWithState(
          lm_pytorch.RNNLM(len(args.char_list), 2, 2)
      )
      init_torch_weight_random(model, (-0.1, 0.1))
      init_torch_weight_random(rnnlm, (-0.1, 0.1))
      model.eval()
      rnnlm.eval()
  
      data = [
          (
              "aaa",
              dict(
                  feat=numpy.random.randn(10, idim).astype(
                      numpy.float32
                  )
              ),
          )
      ]
      in_data = data[0][1]["feat"]
  
      s_nbest_hyps = model.recognize(in_data, args, args.char_list)
      b_nbest_hyps = model.recognize_batch(
          [in_data], args, args.char_list
      )
      assert s_nbest_hyps[0]["yseq"] == b_nbest_hyps[0][0]["yseq"]
      s_nbest_hyps = model.recognize(
          in_data, args, args.char_list, rnnlm
      )
      b_nbest_hyps = model.recognize_batch(
          [in_data], args, args.char_list, rnnlm
      )
      assert s_nbest_hyps[0]["yseq"] == b_nbest_hyps[0][0]["yseq"]
  
      if ctc_weight > 0.0:
          args.ctc_window_margin = 10
          s_nbest_hyps = model.recognize(
              in_data, args, args.char_list, rnnlm
          )
          b_nbest_hyps = model.recognize_batch(
              [in_data], args, args.char_list, rnnlm
          )
          assert s_nbest_hyps[0]["yseq"] == b_nbest_hyps[0][0]["yseq"]
  
      # Test word LM in batch decoding
      rand_range = (-0.01, 0.01)
      torch.manual_seed(1)
      char_list = ["<blank>", "<space>"] + args.char_list + ["<eos>"]
      args = make_small_arg(
          ctc_weight=ctc_weight,
          ctc_window_margin=10,
          beam_size=5,
      )
      model = e2e_asr.E2E(idim, len(char_list), args)
  
      char_dict = {x: i for i, x in enumerate(char_list)}
      word_dict = {x: i for i, x in enumerate(args.word_list)}
  
      word_rnnlm = lm_pytorch.ClassifierWithState(
          lm_pytorch.RNNLM(len(args.word_list), 2, 2)
      )
      rnnlm = lm_pytorch.ClassifierWithState(
          extlm_pytorch.LookAheadWordLM(
              word_rnnlm.predictor, word_dict, char_dict
          )
      )
      init_torch_weight_random(model, rand_range)
      init_torch_weight_random(rnnlm, rand_range)
      model.eval()
      rnnlm.eval()
      s_nbest_hyps = model.recognize(in_data, args, char_list, rnnlm)
      b_nbest_hyps = model.recognize_batch(
          [in_data], args, char_list, rnnlm
      )
      assert s_nbest_hyps[0]["yseq"] == b_nbest_hyps[0][0]["yseq"]
  
file_path: espnet/test/test_recog.py
imports: import argparse
  import numpy
  import pytest
  import torch
  import espnet.lm.pytorch_backend.extlm
  import espnet.nets.pytorch_backend.lm.default
  from espnet.nets.pytorch_backend import e2e_asr
label_desc: Use image node_id 6 for calling a global function with example usage: test_batch_beam_search(ctc_weight) without return types