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 infer(
      self,
      text,
      text_len=None,
      text_mask=None,
      spect=None,
      spect_len=None,
      attn_prior=None,
      use_gt_durs=False,
      lm_tokens=None,
      pitch=None,
  ):
      if text_mask is None:
          text_mask = get_mask_from_lengths(text_len).unsqueeze(2)
  
      enc_out, enc_mask = self.encoder(text, text_mask)
  
      # Aligner
      attn_hard_dur = None
      if use_gt_durs:
          (
              attn_soft,
              attn_logprob,
              attn_hard,
              attn_hard_dur,
          ) = self.run_aligner(
              text, text_len, text_mask, spect, spect_len, attn_prior
          )
  
      if self.cond_on_lm_embeddings:
          lm_emb = self.lm_embeddings(lm_tokens)
          lm_features = self.self_attention_module(
              enc_out,
              lm_emb,
              lm_emb,
              q_mask=enc_mask.squeeze(2),
              kv_mask=lm_tokens != self.lm_padding_value,
          )
  
      # Duration predictor
      log_durs_predicted = self.duration_predictor(enc_out, enc_mask)
      durs_predicted = torch.clamp(log_durs_predicted.exp() - 1, 0)
  
      # Avg pitch, pitch predictor
      if use_gt_durs and pitch is not None:
          pitch = average_features(
              pitch.unsqueeze(1), attn_hard_dur
          ).squeeze(1)
          pitch_emb = self.pitch_emb(pitch.unsqueeze(1))
      else:
          pitch_predicted = self.pitch_predictor(enc_out, enc_mask)
          pitch_emb = self.pitch_emb(pitch_predicted.unsqueeze(1))
  
      # Add pitch emb
      enc_out = enc_out + pitch_emb.transpose(1, 2)
  
      if self.cond_on_lm_embeddings:
          enc_out = enc_out + lm_features
  
      if use_gt_durs:
          if attn_hard_dur is not None:
              len_regulated_enc_out, dec_lens = regulate_len(
                  attn_hard_dur, enc_out
              )
          else:
              raise NotImplementedError
      else:
          len_regulated_enc_out, dec_lens = regulate_len(
              durs_predicted, enc_out
          )
  
      dec_out, _ = self.decoder(
          len_regulated_enc_out,
          get_mask_from_lengths(dec_lens).unsqueeze(2),
      )
      pred_spect = self.proj(dec_out)
  
      return pred_spect
  
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 10 for calling the MixerTTSModel obj's underlying member method code with example usage: obj.infer(text, text_len, text_mask, spect, spect_len, attn_prior, use_gt_durs, lm_tokens, pitch) and returns: pred_spect