class_docstr: The Tactron2 text-to-speech model, based on the NVIDIA implementation.
  
  This class is the main entry point for the model, which is responsible
  for instantiating all submodules, which, in turn, manage the individual
  neural network layers
  
  Simplified STRUCTURE: phoneme input->token embedding ->encoder -> (encoder output + speaker embedding) ->attention     ->decoder(+prenet) -> postnet ->output
  
  prenet(input is decoder previous time step) output is input to decoder
  concatenanted with the attention output
  
  Arguments
  ---------
  spk_emb_size: int
      Speaker embedding size
  
  mask_padding: bool
      whether or not to mask pad-outputs of tacotron
  
  #mel generation parameter in data io
  n_mel_channels: int
      number of mel channels for constructing spectrogram
  
  #symbols
  n_symbols:  int=128
      number of accepted char symbols defined in textToSequence
  symbols_embedding_dim: int
      number of embeding dimension for symbols fed to nn.Embedding
  
  # Encoder parameters
  encoder_kernel_size: int
      size of kernel processing the embeddings
  encoder_n_convolutions: int
      number of convolution layers in encoder
  encoder_embedding_dim: int
      number of kernels in encoder, this is also the dimension
      of the bidirectional LSTM in the encoder
  
  # Attention parameters
  attention_rnn_dim: int
      input dimension
  attention_dim: int
      number of hidden represetation in attention
  # Location Layer parameters
  attention_location_n_filters: int
      number of 1-D convulation filters in attention
  attention_location_kernel_size: int
      length of the 1-D convolution filters
  
  # Decoder parameters
  n_frames_per_step: int=1
      only 1 generated mel-frame per step is supported for the decoder as of now.
  decoder_rnn_dim: int
      number of 2 unidirectionnal stacked LSTM units
  prenet_dim: int
      dimension of linear prenet layers
  max_decoder_steps: int
      maximum number of steps/frames the decoder generates before stopping
  p_attention_dropout: float
      attention drop out probability
  p_decoder_dropout: float
      decoder drop  out probability
  
  gate_threshold: int
      cut off level any output probabilty above that is considered
      complete and stops genration so we have variable length outputs
  decoder_no_early_stopping: bool
      determines early stopping of decoder
      along with gate_threshold . The logical inverse of this is fed to the decoder
  
  
  #Mel-post processing network parameters
  postnet_embedding_dim: int
      number os postnet dfilters
  postnet_kernel_size: int
      1d size of posnet kernel
  postnet_n_convolutions: int
      number of convolution layers in postnet
  
  Example
  -------
  >>> import torch
  >>> _ = torch.manual_seed(213312)
  >>> from speechbrain.lobes.models.Tacotron2 import Tacotron2
  >>> model = Tacotron2(
  ...    mask_padding=True,
  ...    n_mel_channels=80,
  ...    n_symbols=148,
  ...    symbols_embedding_dim=512,
  ...    encoder_kernel_size=5,
  ...    encoder_n_convolutions=3,
  ...    encoder_embedding_dim=512,
  ...    attention_rnn_dim=1024,
  ...    attention_dim=128,
  ...    attention_location_n_filters=32,
  ...    attention_location_kernel_size=31,
  ...    n_frames_per_step=1,
  ...    decoder_rnn_dim=1024,
  ...    prenet_dim=256,
  ...    max_decoder_steps=32,
  ...    gate_threshold=0.5,
  ...    p_attention_dropout=0.1,
  ...    p_decoder_dropout=0.1,
  ...    postnet_embedding_dim=512,
  ...    postnet_kernel_size=5,
  ...    postnet_n_convolutions=5,
  ...    decoder_no_early_stopping=False
  ... )
  >>> _ = model.eval()
  >>> inputs = torch.tensor([
  ...     [13, 12, 31, 14, 19],
  ...     [31, 16, 30, 31, 0],
  ... ])
  >>> input_lengths = torch.tensor([5, 4])
  >>> outputs, output_lengths, alignments = model.infer(inputs, input_lengths)
  >>> outputs.shape, output_lengths.shape, alignments.shape
  (torch.Size([2, 80, 1]), torch.Size([2]), torch.Size([2, 1, 5]))
docstr: Decoder forward pass for training
  
  Arguments
  ---------
  inputs: tuple
      batch object
  spk_embs: torch.Tensor
      Speaker embeddings corresponding to the inputs
  alignments_dim: int
      the desired dimension of the alignments along the last axis
      Optional but needed for data-parallel training
  
  Returns
  ---------
  mel_outputs: torch.Tensor
      mel outputs from the decoder
  mel_outputs_postnet: torch.Tensor
      mel outputs from postnet
  gate_outputs: torch.Tensor
      gate outputs from the decoder
  alignments: torch.Tensor
      sequence of attention weights from the decoder
  output_legnths: torch.Tensor
      length of the output without padding
docstr_tok: ["Decoder","forward","pass","for","training","Arguments","--","--","--","--","-","inputs",":","tuple","batch","object","spk_embs",":","torch.Tensor","Speaker","embeddings","corresponding","to","the","inputs","alignments_dim",":","int","the","desired","dimension","of","the","alignments","along","the","last","axis","Optional","but","needed","for","data-parallel","training","Returns","--","--","--","--","-","mel_outputs",":","torch.Tensor","mel","outputs","from","the","decoder","mel_outputs_postnet",":","torch.Tensor","mel","outputs","from","postnet","gate_outputs",":","torch.Tensor","gate","outputs","from","the","decoder","alignments",":","torch.Tensor","sequence","of","attention","weights","from","the","decoder","output_legnths",":","torch.Tensor","length","of","the","output","without","padding"]
code: def forward(self, inputs, spk_embs, alignments_dim=None):
      """Decoder forward pass for training
  
      Arguments
      ---------
      inputs: tuple
          batch object
      spk_embs: torch.Tensor
          Speaker embeddings corresponding to the inputs
      alignments_dim: int
          the desired dimension of the alignments along the last axis
          Optional but needed for data-parallel training
  
      Returns
      ---------
      mel_outputs: torch.Tensor
          mel outputs from the decoder
      mel_outputs_postnet: torch.Tensor
          mel outputs from postnet
      gate_outputs: torch.Tensor
          gate outputs from the decoder
      alignments: torch.Tensor
          sequence of attention weights from the decoder
      output_legnths: torch.Tensor
          length of the output without padding
      """
      inputs, input_lengths, targets, max_len, output_lengths = inputs
      input_lengths, output_lengths = (
          input_lengths.data,
          output_lengths.data,
      )
  
      embedded_inputs = self.embedding(inputs).transpose(1, 2)
      encoder_outputs = self.encoder(embedded_inputs, input_lengths)
  
      # Inject speaker embeddings into the encoder output
      spk_embs_shared = F.relu(self.ms_film_hidden(spk_embs))
  
      spk_embs_h = self.ms_film_h(spk_embs_shared)
      spk_embs_h = torch.unsqueeze(spk_embs_h, 1).repeat(
          1, encoder_outputs.shape[1], 1
      )
      encoder_outputs = encoder_outputs * spk_embs_h
  
      spk_embs_g = self.ms_film_g(spk_embs_shared)
      spk_embs_g = torch.unsqueeze(spk_embs_g, 1).repeat(
          1, encoder_outputs.shape[1], 1
      )
      encoder_outputs = encoder_outputs + spk_embs_g
  
      # Pass the encoder output combined with speaker embeddings to the next layers
      mel_outputs, gate_outputs, alignments = self.decoder(
          encoder_outputs, targets, memory_lengths=input_lengths
      )
  
      mel_outputs_postnet = self.postnet(mel_outputs)
      mel_outputs_postnet = mel_outputs + mel_outputs_postnet
  
      return self.parse_output(
          [mel_outputs, mel_outputs_postnet, gate_outputs, alignments],
          output_lengths,
          alignments_dim,
      )
  
imports: from math import sqrt
  from speechbrain.nnet.loss.guidedattn_loss import GuidedAttentionLoss
  import torch
  from torch import nn
  from torch.nn import functional
  from collections import namedtuple
  import pickle
  from speechbrain.lobes.models.Tacotron2 import LinearNorm, Postnet, Encoder, Decoder, get_mask_from_lengths
label_desc: Use image node_id 3 for calling the Tacotron2 obj's underlying member method code with example usage: obj.forward(inputs, spk_embs, alignments_dim) and returns: self