class_docstr: GAN-based text-to-speech task.
code: def build_model(cls, args: argparse.Namespace) -> ESPnetGANTTSModel:
      assert check_argument_types()
      if isinstance(args.token_list, str):
          with open(args.token_list, encoding="utf-8") as f:
              token_list = [line[0] + line[1:].rstrip() for line in f]
  
          # "args" is saved as it is in a yaml file by BaseTask.main().
          # Overwriting token_list to keep it as "portable".
          args.token_list = token_list.copy()
      elif isinstance(args.token_list, (tuple, list)):
          token_list = args.token_list.copy()
      else:
          raise RuntimeError("token_list must be str or dict")
  
      vocab_size = len(token_list)
      logging.info(f"Vocabulary size: {vocab_size }")
  
      # 1. feats_extract
      if args.odim is None:
          # Extract features in the model
          feats_extract_class = feats_extractor_choices.get_class(
              args.feats_extract
          )
          feats_extract = feats_extract_class(**args.feats_extract_conf)
          odim = feats_extract.output_size()
      else:
          # Give features from data-loader
          args.feats_extract = None
          args.feats_extract_conf = None
          feats_extract = None
          odim = args.odim
  
      # 2. 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
  
      # 3. TTS
      tts_class = tts_choices.get_class(args.tts)
      tts = tts_class(idim=vocab_size, odim=odim, **args.tts_conf)
  
      # 4. Extra components
      pitch_extract = None
      energy_extract = None
      pitch_normalize = None
      energy_normalize = None
      if getattr(args, "pitch_extract", None) is not None:
          pitch_extract_class = pitch_extractor_choices.get_class(
              args.pitch_extract,
          )
          pitch_extract = pitch_extract_class(
              **args.pitch_extract_conf,
          )
      if getattr(args, "energy_extract", None) is not None:
          energy_extract_class = energy_extractor_choices.get_class(
              args.energy_extract,
          )
          energy_extract = energy_extract_class(
              **args.energy_extract_conf,
          )
      if getattr(args, "pitch_normalize", None) is not None:
          pitch_normalize_class = pitch_normalize_choices.get_class(
              args.pitch_normalize,
          )
          pitch_normalize = pitch_normalize_class(
              **args.pitch_normalize_conf,
          )
      if getattr(args, "energy_normalize", None) is not None:
          energy_normalize_class = energy_normalize_choices.get_class(
              args.energy_normalize,
          )
          energy_normalize = energy_normalize_class(
              **args.energy_normalize_conf,
          )
  
      # 5. Build model
      model = ESPnetGANTTSModel(
          feats_extract=feats_extract,
          normalize=normalize,
          pitch_extract=pitch_extract,
          pitch_normalize=pitch_normalize,
          energy_extract=energy_extract,
          energy_normalize=energy_normalize,
          tts=tts,
          **args.model_conf,
      )
      assert check_return_type(model)
      return model
  
imports: import argparse
  import logging
  from typing import Callable, Collection, Dict, List, Optional, Tuple
  import numpy
  import torch
  from typeguard import check_argument_types, check_return_type
  from espnet2.gan_tts.abs_gan_tts import AbsGANTTS
  from espnet2.gan_tts.espnet_model import ESPnetGANTTSModel
  from espnet2.gan_tts.jets import JETS
  from espnet2.gan_tts.joint import JointText2Wav
  from espnet2.gan_tts.vits import VITS
  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, optim_classes
  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.gan_trainer import GANTrainer
  from espnet2.train.preprocessor import CommonPreprocessor
  from espnet2.tts.feats_extract.abs_feats_extract import AbsFeatsExtract
  from espnet2.tts.feats_extract.dio import Dio
  from espnet2.tts.feats_extract.energy import Energy
  from espnet2.tts.feats_extract.linear_spectrogram import LinearSpectrogram
  from espnet2.tts.feats_extract.log_mel_fbank import LogMelFbank
  from espnet2.tts.feats_extract.log_spectrogram import LogSpectrogram
  from espnet2.utils.get_default_kwargs import get_default_kwargs
  from espnet2.utils.nested_dict_action import NestedDictAction
  from espnet2.utils.types import int_or_none, str2bool, str_or_none
label_desc: Use image node_id 6 for calling the GANTTSTask obj's underlying member method code with example usage: obj.build_model(cls, args) and returns: model