code: def __init__(self, cfg: DictConfig, trainer: Trainer = None):
      if isinstance(cfg, dict):
          cfg = OmegaConf.create(cfg)
      self.normalizer = None
      self.text_normalizer_call = None
      self.text_normalizer_call_kwargs = {}
      self._setup_normalizer(cfg)
  
      self.tokenizer = None
      self._setup_tokenizer(cfg)
  
      assert self.tokenizer is not None
  
      self.tokenizer_pad = self.tokenizer.pad
      self.tokenizer_unk = self.tokenizer.oov
  
      self.text_tokenizer_pad_id = None
      self.tokens = None
  
      super().__init__(cfg=cfg, trainer=trainer)
      self.feat_loss_weight = 1.0
      self.model_config = cfg.modelConfig
      self.train_config = cfg.trainerConfig
      self.optim = cfg.optim
      self.criterion = RADTTSLoss(
          self.train_config.sigma,
          self.model_config.n_group_size,
          self.model_config.dur_model_config,
          self.model_config.f0_model_config,
          self.model_config.energy_model_config,
          vpred_model_config=self.model_config.v_model_config,
          loss_weights=self.train_config.loss_weights,
      )
  
      self.attention_kl_loss = AttentionBinarizationLoss()
      self.model = instantiate(cfg.modelConfig)
      self._parser = None
      self._tb_logger = None
      self.cfg = cfg
      self.log_train_images = False
      self.export_config = {
          "emb_range": (0, self.model.embedding.num_embeddings),
          "enable_volume": True,
          "enable_ragged_batches": False,
          "num_speakers": self.model_config.n_speakers,
      }
  
imports: import contextlib
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig, OmegaConf
  from pytorch_lightning import Trainer
  from pytorch_lightning.loggers import TensorBoardLogger
  from nemo.collections.common.tokenizers.text_to_speech.tts_tokenizers import BaseTokenizer
  from nemo.collections.tts.losses.radttsloss import AttentionBinarizationLoss, RADTTSLoss
  from nemo.collections.tts.models.base import SpectrogramGenerator
  from nemo.collections.tts.parts.utils.helpers import batch_from_ragged, g2p_backward_compatible_support, plot_alignment_to_numpy, regulate_len, sample_tts_input
  from nemo.core.classes import Exportable
  from nemo.core.classes.common import typecheck
  from nemo.core.neural_types.elements import Index, MelSpectrogramType, RegressionValuesType, TokenDurationType, TokenIndex
  from nemo.core.neural_types.neural_type import NeuralType
  from nemo.core.optim.radam import RAdam
  from nemo.utils import logging
  from nemo.utils.decorators import experimental
label_desc: Use image node_id 1 to create a new RadTTSModel object from inherited base classes: SpectrogramGenerator, Exportable with example: obj = RadTTSModel(cfg, trainer)