class_docstr: Speech2Text class
  
  Examples:
      >>> import soundfile
      >>> speech2text = k2Speech2Text("uasr_config.yml", "uasr.pth")
      >>> audio, rate = soundfile.read("speech.wav")
      >>> speech = np.expand_dims(audio, 0) # shape: [batch_size, speech_length]
      >>> speech_lengths = np.array([audio.shape[0]]) # shape: [batch_size]
      >>> batch = {"speech": speech, "speech_lengths", speech_lengths}
      >>> speech2text(batch)
      [(text, token, token_int, score), ...]
code: def __init__(
      self,
      uasr_train_config: Union[Path, str],
      decoding_graph: str,
      uasr_model_file: Union[Path, str] = None,
      lm_train_config: Union[Path, str] = None,
      lm_file: Union[Path, str] = None,
      token_type: str = None,
      bpemodel: str = None,
      device: str = "cpu",
      maxlenratio: float = 0.0,
      minlenratio: float = 0.0,
      batch_size: int = 1,
      dtype: str = "float32",
      beam_size: int = 8,
      ctc_weight: float = 0.5,
      lm_weight: float = 1.0,
      penalty: float = 0.0,
      nbest: int = 1,
      streaming: bool = False,
      search_beam_size: int = 20,
      output_beam_size: int = 20,
      min_active_states: int = 14000,
      max_active_states: int = 56000,
      blank_bias: float = 0.0,
      lattice_weight: float = 1.0,
      is_ctc_decoding: bool = True,
      lang_dir: Optional[str] = None,
      token_list_file: Optional[str] = None,
      use_fgram_rescoring: bool = False,
      use_nbest_rescoring: bool = False,
      am_weight: float = 0.5,
      decoder_weight: float = 0.5,
      nnlm_weight: float = 1.0,
      num_paths: int = 1000,
      nbest_batch_size: int = 500,
      nll_batch_size: int = 100,
  ):
      assert check_argument_types()
  
      # 1. Build UASR model
      uasr_model, uasr_train_args = UASRTask.build_model_from_file(
          uasr_train_config, uasr_model_file, device
      )
      uasr_model.use_collected_training_feats = True
      uasr_model.to(dtype=getattr(torch, dtype)).eval()
  
      if token_list_file is not None:
          token_list = []
          with open(token_list_file, "r") as tlf:
              for line in tlf.readlines():
                  token, _ = line.split()
                  assert token not in token_list
                  token_list.append(token)
      else:
          token_list = uasr_model.token_list
  
      # 2. Build Language model
      if lm_train_config is not None:
          lm, lm_train_args = LMTask.build_model_from_file(
              lm_train_config, lm_file, device
          )
          self.lm = lm
  
      self.is_ctc_decoding = is_ctc_decoding
      self.use_fgram_rescoring = use_fgram_rescoring
      self.use_nbest_rescoring = use_nbest_rescoring
  
      # load decoding graph
      self.decoding_graph = k2.Fsa.from_dict(torch.load(decoding_graph))
      self.decoding_graph = self.decoding_graph.to(device)
  
      assert token_type is not None
      tokenizer = build_tokenizer(token_type=token_type)
      converter = TokenIDConverter(token_list=token_list)
      logging.info(f"Text tokenizer: {tokenizer}")
      logging.info(f"Running on : {device}")
  
      self.uasr_model = uasr_model
      self.uasr_train_args = uasr_train_args
      self.converter = converter
      self.tokenizer = tokenizer
      self.device = device
      self.dtype = dtype
      self.search_beam_size = search_beam_size
      self.output_beam_size = output_beam_size
      self.min_active_states = min_active_states
      self.max_active_states = max_active_states
      self.blank_bias = blank_bias
      self.lattice_weight = lattice_weight
      self.am_weight = am_weight
      self.decoder_weight = decoder_weight
      self.nnlm_weight = nnlm_weight
      self.num_paths = num_paths
      self.nbest_batch_size = nbest_batch_size
      self.nll_batch_size = nll_batch_size
      self.uasr_model_ignore_id = 0
  
imports: import argparse
  import datetime
  import logging
  import sys
  from pathlib import Path
  from typing import Any, List, Optional, Sequence, Tuple, Union
  import numpy
  import torch
  import yaml
  from typeguard import check_argument_types, check_return_type
  from espnet2.fileio.datadir_writer import DatadirWriter
  from espnet2.tasks.lm import LMTask
  from espnet2.tasks.uasr import UASRTask
  from espnet2.text.build_tokenizer import build_tokenizer
  from espnet2.text.token_id_converter import TokenIDConverter
  from espnet2.torch_utils.device_funcs import to_device
  from espnet2.torch_utils.set_all_random_seed import set_all_random_seed
  from espnet2.utils import config_argparse
  from espnet2.utils.types import str2bool, str2triple_str, str_or_none
  from espnet.nets.pytorch_backend.transformer.subsampling import TooShortUttError
  from espnet.utils.cli_utils import get_commandline_args
label_desc: Use image node_id 1 to create a new k2Speech2Text object  with example: obj = k2Speech2Text(uasr_train_config, decoding_graph, uasr_model_file, lm_train_config, lm_file, token_type, bpemodel, device, maxlenratio, minlenratio, batch_size, dtype, beam_size, ctc_weight, lm_weight, penalty, nbest, streaming, search_beam_size, output_beam_size, min_active_states, max_active_states, blank_bias, lattice_weight, is_ctc_decoding, lang_dir, token_list_file, use_fgram_rescoring, use_nbest_rescoring, am_weight, decoder_weight, nnlm_weight, num_paths, nbest_batch_size, nll_batch_size)