class_docstr: GAN-based text-to-speech task.
code: def build_optimizers(
      cls,
      args: argparse.Namespace,
      model: ESPnetGANTTSModel,
  ) -> List[torch.optim.Optimizer]:
      # check
      assert hasattr(model.tts, "generator")
      assert hasattr(model.tts, "discriminator")
  
      # define generator optimizer
      optim_g_class = optim_classes.get(args.optim)
      if optim_g_class is None:
          raise ValueError(
              f"must be one of {list(optim_classes)}: {args.optim}"
          )
      if args.sharded_ddp:
          try:
              import fairscale
          except ImportError:
              raise RuntimeError(
                  "Requiring fairscale. Do 'pip install fairscale'"
              )
          optim_g = fairscale.optim.oss.OSS(
              params=model.tts.generator.parameters(),
              optim=optim_g_class,
              **args.optim_conf,
          )
      else:
          optim_g = optim_g_class(
              model.tts.generator.parameters(),
              **args.optim_conf,
          )
      optimizers = [optim_g]
  
      # define discriminator optimizer
      optim_d_class = optim_classes.get(args.optim2)
      if optim_d_class is None:
          raise ValueError(
              f"must be one of {list(optim_classes)}: {args.optim2}"
          )
      if args.sharded_ddp:
          try:
              import fairscale
          except ImportError:
              raise RuntimeError(
                  "Requiring fairscale. Do 'pip install fairscale'"
              )
          optim_d = fairscale.optim.oss.OSS(
              params=model.tts.discriminator.parameters(),
              optim=optim_d_class,
              **args.optim2_conf,
          )
      else:
          optim_d = optim_d_class(
              model.tts.discriminator.parameters(),
              **args.optim2_conf,
          )
      optimizers += [optim_d]
  
      return optimizers
  
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 7 for calling the GANTTSTask obj's underlying member method code with example usage: obj.build_optimizers(cls, args, model) and returns: optimizers