class_docstr: Beam search implementation for Transducer.
docstr: Perform beam search.
  
  Args:
      enc_out: Encoder output sequence. (T, D_enc)
  
  Returns:
      nbest_hyps: N-best decoding results
docstr_tok: ["Perform","beam","search",".","Args",":","enc_out",":","Encoder","output","sequence",".","(","T",",","D_enc",")","Returns",":","nbest_hyps",":","N-best","decoding","results"]
code: def __call__(
      self,
      enc_out: torch.Tensor,
      start_idx: int = 0,
      is_final: bool = False,
      incremental_decode: bool = False,
  ) -> Union[List[Hypothesis], List[ExtendedHypothesis]]:
      """Perform beam search.
  
      Args:
          enc_out: Encoder output sequence. (T, D_enc)
  
      Returns:
          nbest_hyps: N-best decoding results
  
      """
      self.decoder.set_device(enc_out.device)
  
      nbest_hyps = self.search_algorithm(enc_out[start_idx:])
  
      if incremental_decode:
          # prune hyps not containing top hyp as a prefix
          if len(nbest_hyps[0].yseq) > self.hold_n and not is_final:
              inc = nbest_hyps[0].yseq[
                  : len(nbest_hyps[0].yseq) - self.hold_n
              ]
              logging.debug(
                  "top hyp: "
                  + "".join(
                      [self.token_list[x] for x in nbest_hyps[0].yseq]
                  )
              )
              logging.debug(
                  "top hyp hold_n: "
                  + "".join([self.token_list[x] for x in inc])
              )
          else:
              inc = nbest_hyps[0].yseq
          new_B = [nbest_hyps[0]]
          for h in nbest_hyps[1:]:
              if len(h.yseq) <= len(inc):
                  continue
              keep = True
              for i in range(len(inc)):
                  if inc[i] != h.yseq[i]:
                      keep = False
                      break
              if keep:
                  new_B.append(h)
          logging.debug(f"hyps after inc pruning: {len(new_B)}")
  
          self.B = new_B
  
          ret = [
              Hypothesis2(
                  yseq=torch.tensor(list(inc) + [self.sos]),
                  score=nbest_hyps[0].score,
              )
          ]
      else:
          ret = [
              Hypothesis2(
                  yseq=torch.tensor(h.yseq + [self.sos]), score=h.score
              )
              for h in nbest_hyps
          ]
  
      if is_final:
          self.reset()
  
      return ret
  
imports: import logging
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.joint_network import JointNetwork
  from espnet2.lm.transformer_lm import TransformerLM
  from espnet.nets.beam_search import Hypothesis
  from espnet.nets.pytorch_backend.transducer.utils import is_prefix, recombine_hyps, select_k_expansions, subtract
label_desc: Use image node_id 2 for calling the BeamSearchTransducerStreaming obj's underlying member method code with example usage: obj.__call__(enc_out, start_idx, is_final, incremental_decode) and returns: ret