class_docstr: ASR Transducer Task definition.
class_docstr_tok: ["ASR","Transducer","Task","definition","."]
docstr: Required data depending on task mode.
  
  Args:
      cls: ASRTransducerTask object.
      args: Task arguments.
  
  Return:
      model: ASR Transducer model.
docstr_tok: ["Required","data","depending","on","task","mode",".","Args",":","cls",":","ASRTransducerTask","object",".","args",":","Task","arguments",".","Return",":","model",":","ASR","Transducer","model","."]
code: def build_model(
      cls, args: argparse.Namespace
  ) -> ESPnetASRTransducerModel:
      """Required data depending on task mode.
  
      Args:
          cls: ASRTransducerTask object.
          args: Task arguments.
  
      Return:
          model: ASR Transducer model.
  
      """
      assert check_argument_types()
  
      if isinstance(args.token_list, str):
          with open(args.token_list, encoding="utf-8") as f:
              token_list = [line.rstrip() for line in f]
  
          # Overwriting token_list to keep it as "portable".
          args.token_list = list(token_list)
      elif isinstance(args.token_list, (tuple, list)):
          token_list = list(args.token_list)
      else:
          raise RuntimeError("token_list must be str or list")
      vocab_size = len(token_list)
  
      if hasattr(args, "scheduler_conf"):
          args.model_conf["warmup_steps"] = args.scheduler_conf.get(
              "warmup_steps", 25000
          )
  
      logging.info(f"Vocabulary size: {vocab_size }")
  
      # 1. frontend
      if args.input_size is None:
          # Extract features in the model
          frontend_class = frontend_choices.get_class(args.frontend)
          frontend = frontend_class(**args.frontend_conf)
          input_size = frontend.output_size()
      else:
          # Give features from data-loader
          frontend = None
          input_size = args.input_size
  
      # 2. Data augmentation for spectrogram
      if args.specaug is not None:
          specaug_class = specaug_choices.get_class(args.specaug)
          specaug = specaug_class(**args.specaug_conf)
      else:
          specaug = None
  
      # 3. Normalization layer
      if args.normalize is not None:
          normalize_class = normalize_choices.get_class(args.normalize)
          normalize = normalize_class(**args.normalize_conf)
      else:
          normalize = None
  
      # 4. Encoder
      encoder = Encoder(input_size, **args.encoder_conf)
      encoder_output_size = encoder.output_size
  
      # 5. Decoder
      decoder_class = decoder_choices.get_class(args.decoder)
  
      decoder = decoder_class(
          vocab_size,
          **args.decoder_conf,
      )
      decoder_output_size = decoder.output_size
  
      # 6. Joint Network
      joint_network = JointNetwork(
          vocab_size,
          encoder_output_size,
          decoder_output_size,
          **args.joint_network_conf,
      )
  
      # 7. Build model
      model = ESPnetASRTransducerModel(
          vocab_size=vocab_size,
          token_list=token_list,
          frontend=frontend,
          specaug=specaug,
          normalize=normalize,
          encoder=encoder,
          decoder=decoder,
          joint_network=joint_network,
          **args.model_conf,
      )
  
      # 8. Initialize model
      if args.init is not None:
          raise NotImplementedError(
              "Currently not supported.",
              "Initialization part will be reworked in a short future.",
          )
  
      assert check_return_type(model)
  
      return model
  
imports: import argparse
  import logging
  import os
  from typing import Callable, Collection, Dict, List, Optional, Tuple
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.frontend.default import DefaultFrontend
  from espnet2.asr.frontend.windowing import SlidingWindow
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.asr.specaug.specaug import SpecAug
  from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.decoder.mega_decoder import MEGADecoder
  from espnet2.asr_transducer.decoder.rnn_decoder import RNNDecoder
  from espnet2.asr_transducer.decoder.rwkv_decoder import RWKVDecoder
  from espnet2.asr_transducer.decoder.stateless_decoder import StatelessDecoder
  from espnet2.asr_transducer.encoder.encoder import Encoder
  from espnet2.asr_transducer.espnet_transducer_model import ESPnetASRTransducerModel
  from espnet2.asr_transducer.joint_network import JointNetwork
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.layers.global_mvn import GlobalMVN
  from espnet2.layers.utterance_mvn import UtteranceMVN
  from espnet2.tasks.abs_task import AbsTask
  from espnet2.text.phoneme_tokenizer import g2p_choices
  from espnet2.train.class_choices import ClassChoices
  from espnet2.train.collate_fn import CommonCollateFn
  from espnet2.train.preprocessor import CommonPreprocessor
  from espnet2.train.trainer import Trainer
  from espnet2.utils.get_default_kwargs import get_default_kwargs
  from espnet2.utils.nested_dict_action import NestedDictAction
  from espnet2.utils.types import float_or_none, int_or_none, str2bool, str_or_none
label_desc: Use image node_id 6 for calling the ASRTransducerTask obj's underlying member method code with example usage: obj.build_model(cls, args) and returns: model