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 _setup_tokenizer(self, cfg):
      text_tokenizer_kwargs = {}
      if "g2p" in cfg.text_tokenizer:
          # for backward compatibility
          if (
              self._is_model_being_restored()
              and (
                  cfg.text_tokenizer.g2p.get("_target_", None)
                  is not None
              )
              and cfg.text_tokenizer.g2p["_target_"].startswith(
                  "nemo_text_processing.g2p"
              )
          ):
              cfg.text_tokenizer.g2p[
                  "_target_"
              ] = g2p_backward_compatible_support(
                  cfg.text_tokenizer.g2p["_target_"]
              )
  
          g2p_kwargs = {}
  
          if "phoneme_dict" in cfg.text_tokenizer.g2p:
              g2p_kwargs["phoneme_dict"] = self.register_artifact(
                  "text_tokenizer.g2p.phoneme_dict",
                  cfg.text_tokenizer.g2p.phoneme_dict,
              )
  
          if "heteronyms" in cfg.text_tokenizer.g2p:
              g2p_kwargs["heteronyms"] = self.register_artifact(
                  "text_tokenizer.g2p.heteronyms",
                  cfg.text_tokenizer.g2p.heteronyms,
              )
  
          text_tokenizer_kwargs["g2p"] = instantiate(
              cfg.text_tokenizer.g2p, **g2p_kwargs
          )
  
      self.tokenizer = instantiate(
          cfg.text_tokenizer, **text_tokenizer_kwargs
      )
  
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 3 for calling the MixerTTSModel obj's underlying member method code with example usage: obj._setup_tokenizer(cfg) without return types