class_docstr: Mixer-TTS and Mixer-TTS-X models (https://arxiv.org/abs/2110.03584) that is used to generate mel spectrogram from text.
class_docstr_tok: ["Mixer-TTS","and","Mixer-TTS-X","models","(","https",":","\/\/arxiv.org\/abs\/2110.03584",")","that","is","used","to","generate","mel","spectrogram","from","text","."]
code: def __init__(self, cfg: DictConfig, trainer: "Trainer" = None):
      # Convert to Hydra 1.0 compatible DictConfig
      cfg = model_utils.convert_model_config_to_dict_config(cfg)
      cfg = model_utils.maybe_update_config_version(cfg)
  
      # Setup normalizer
      self.normalizer = None
      self.text_normalizer_call = None
      self.text_normalizer_call_kwargs = {}
      self._setup_normalizer(cfg)
  
      # Setup tokenizer
      self.tokenizer = None
      self._setup_tokenizer(cfg)
      assert self.tokenizer is not None
  
      num_tokens = len(self.tokenizer.tokens)
      self.tokenizer_pad = self.tokenizer.pad
      self.tokenizer_unk = self.tokenizer.oov
  
      super().__init__(cfg=cfg, trainer=trainer)
  
      self.pitch_loss_scale = cfg.pitch_loss_scale
      self.durs_loss_scale = cfg.durs_loss_scale
      self.mel_loss_scale = cfg.mel_loss_scale
  
      self.aligner = instantiate(cfg.alignment_module)
      self.forward_sum_loss = ForwardSumLoss()
      self.bin_loss = BinLoss()
      self.add_bin_loss = False
      self.bin_loss_scale = 0.0
      self.bin_loss_start_ratio = cfg.bin_loss_start_ratio
      self.bin_loss_warmup_epochs = cfg.bin_loss_warmup_epochs
  
      self.cond_on_lm_embeddings = cfg.get(
          "cond_on_lm_embeddings", False
      )
  
      if self.cond_on_lm_embeddings:
          self.lm_padding_value = (
              self._train_dl.dataset.lm_padding_value
              if self._train_dl is not None
              else self._get_lm_padding_value(cfg.lm_model)
          )
          self.lm_embeddings = self._get_lm_embeddings(cfg.lm_model)
          self.lm_embeddings.weight.requires_grad = False
  
          self.self_attention_module = instantiate(
              cfg.self_attention_module,
              n_lm_tokens_channels=self.lm_embeddings.weight.shape[1],
          )
  
      self.encoder = instantiate(
          cfg.encoder,
          num_tokens=num_tokens,
          padding_idx=self.tokenizer_pad,
      )
      self.symbol_emb = self.encoder.to_embed
  
      self.duration_predictor = instantiate(cfg.duration_predictor)
  
      self.pitch_mean, self.pitch_std = float(cfg.pitch_mean), float(
          cfg.pitch_std
      )
      self.pitch_predictor = instantiate(cfg.pitch_predictor)
      self.pitch_emb = instantiate(cfg.pitch_emb)
  
      self.preprocessor = instantiate(cfg.preprocessor)
  
      self.decoder = instantiate(cfg.decoder)
      self.proj = nn.Linear(self.decoder.d_model, cfg.n_mel_channels)
  
imports: import contextlib
  from typing import List, Optional
  import numpy
  import omegaconf
  import torch
  import transformers
  import wandb
  from hydra.utils import instantiate
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from pytorch_lightning.loggers import WandbLogger
  from torch import nn
  from torch.nn import functional
  from transformers import AlbertTokenizer
  from nemo.collections.common.tokenizers.text_to_speech.tts_tokenizers import EnglishCharsTokenizer, EnglishPhonemesTokenizer
  from nemo.collections.tts.losses.aligner_loss import BinLoss, ForwardSumLoss
  from nemo.collections.tts.models.base import SpectrogramGenerator
  from nemo.collections.tts.modules.fastpitch import average_features, regulate_len
  from nemo.collections.tts.parts.utils.helpers import binarize_attention_parallel, g2p_backward_compatible_support, get_mask_from_lengths, plot_pitch_to_numpy, plot_spectrogram_to_numpy
  from nemo.core import Exportable
  from nemo.core.classes.common import PretrainedModelInfo, typecheck
  from nemo.core.neural_types.elements import LengthsType, LogprobsType, MelSpectrogramType, ProbsType, RegressionValuesType, TokenDurationType, TokenIndex, TokenLogDurationType
  from nemo.core.neural_types.neural_type import NeuralType
  from nemo.utils import logging, model_utils
label_desc: Use image node_id 1 to create a new MixerTTSModel object from inherited base classes: SpectrogramGenerator, Exportable with example: obj = MixerTTSModel(cfg, trainer)