class_docstr: Base `tts` class. Every new `tts` model must inherit this.
  
  It defines common `tts` specific functions on top of `Model` implementation.
class_docstr_tok: ["Base","`","tts","`","class",".","Every","new","`","tts","`","model","must","inherit","this",".","It","defines","common","`","tts","`","specific","functions","on","top","of","`","Model","`","implementation","."]
docstr: Setup model args based on the config type (`ModelConfig` or `ModelArgs`).
  
  `ModelArgs` has all the fields reuqired to initialize the model architecture.
  
  `ModelConfig` has all the fields required for training, inference and containes `ModelArgs`.
  
  If the config is for training with a name like "*Config", then the model args are embeded in the
  config.model_args
  
  If the config is for the model with a name like "*Args", then we assign the directly.
docstr_tok: ["Setup","model","args","based","on","the","config","type","(","`","ModelConfig","`","or","`","ModelArgs","`",")",".","`","ModelArgs","`","has","all","the","fields","reuqired","to","initialize","the","model","architecture",".","`","ModelConfig","`","has","all","the","fields","required","for","training",",","inference","and","containes","`","ModelArgs","`",".","If","the","config","is","for","training","with","a","name","like","``","*","Config","''",",","then","the","model","args","are","embeded","in","the","config.model_args","If","the","config","is","for","the","model","with","a","name","like","``","*","Args","''",",","then","we","assign","the","directly","."]
code: def _set_model_args(self, config: Coqpit):
      """Setup model args based on the config type (`ModelConfig` or `ModelArgs`).
  
      `ModelArgs` has all the fields reuqired to initialize the model architecture.
  
      `ModelConfig` has all the fields required for training, inference and containes `ModelArgs`.
  
      If the config is for training with a name like "*Config", then the model args are embeded in the
      config.model_args
  
      If the config is for the model with a name like "*Args", then we assign the directly.
      """
      # don't use isintance not to import recursively
      if "Config" in config.__class__.__name__:
          config_num_chars = (
              self.config.model_args.num_chars
              if hasattr(self.config, "model_args")
              else self.config.num_chars
          )
          num_chars = (
              config_num_chars
              if self.tokenizer is None
              else self.tokenizer.characters.num_chars
          )
          if "characters" in config:
              self.config.num_chars = num_chars
              if hasattr(self.config, "model_args"):
                  config.model_args.num_chars = num_chars
                  self.args = self.config.model_args
          else:
              self.config = config
              self.args = config.model_args
      elif "Args" in config.__class__.__name__:
          self.args = config
      else:
          raise ValueError("config must be either a *Config or *Args")
  
imports: import os
  import random
  from typing import Dict, List, Tuple, Union
  import torch
  import torch.distributed
  from coqpit import Coqpit
  from torch import nn
  from torch.utils.data import DataLoader
  from torch.utils.data.sampler import WeightedRandomSampler
  from trainer.torch import DistributedSampler, DistributedSamplerWrapper
  from TTS.model import BaseTrainerModel
  from TTS.tts.datasets.dataset import TTSDataset
  from TTS.tts.utils.data import get_length_balancer_weights
  from TTS.tts.utils.languages import LanguageManager, get_language_balancer_weights
  from TTS.tts.utils.speakers import SpeakerManager, get_speaker_balancer_weights, get_speaker_manager
  from TTS.tts.utils.synthesis import synthesis
  from TTS.tts.utils.visual import plot_alignment, plot_spectrogram
label_desc: Use image node_id 2 for calling the BaseTTS obj's underlying member method code with example usage: obj._set_model_args(config) without return types