code: def build_model(
      cls, args: argparse.Namespace
  ) -> Union[HubertPretrainModel, TorchAudioHubertPretrainModel]:
      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)
      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
          args.frontend = None
          args.frontend_conf = {**args.frontend_conf}
          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. Pre-encoder input block
      # NOTE(kan-bayashi): Use getattr to keep the compatibility
      if getattr(args, "preencoder", None) is not None:
          preencoder_class = preencoder_choices.get_class(
              args.preencoder
          )
          preencoder = preencoder_class(**args.preencoder_conf)
          input_size = preencoder.output_size()
      else:
          preencoder = None
  
      # 4. Encoder
      encoder_class = encoder_choices.get_class(args.encoder)
      encoder = encoder_class(
          input_size=input_size,
          num_classes=args.num_classes,
          **args.encoder_conf,
      )
  
      # 8. Build model
      try:
          model_class = model_choices.get_class(args.model)
      except AttributeError:
          model_class = model_choices.get_class("fairseq")
      model = model_class(
          vocab_size=vocab_size,
          frontend=frontend,
          specaug=specaug,
          normalize=normalize,
          preencoder=preencoder,
          encoder=encoder,
          token_list=token_list,
          **args.model_conf,
      )
  
      # 9. Initialize
      if args.init is not None:
          initialize(model, args.init)
  
      assert check_return_type(model)
      return model
  
imports: import argparse
  import logging
  from typing import Callable, Collection, Dict, List, Optional, Tuple, Union
  import humanfriendly
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.encoder.hubert_encoder import FairseqHubertPretrainEncoder, TorchAudioHuBERTPretrainEncoder
  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.preencoder.abs_preencoder import AbsPreEncoder
  from espnet2.asr.preencoder.sinc import LightweightSincConvs
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.asr.specaug.specaug import SpecAug
  from espnet2.hubert.espnet_model import HubertPretrainModel, TorchAudioHubertPretrainModel
  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.torch_utils.initialize import initialize
  from espnet2.train.abs_espnet_model import AbsESPnetModel
  from espnet2.train.class_choices import ClassChoices
  from espnet2.train.collate_fn import HuBERTCollateFn
  from espnet2.train.preprocessor import CommonPreprocessor
  from espnet2.train.trainer import Trainer
  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 HubertTask obj's underlying member method code with example usage: obj.build_model(cls, args) and returns: model