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: input->word embedding ->encoder ->attention     ->decoder(+prenet) -> postnet ->output
  
  prenet(input is decoder previous time step) output is input to decoder
  concatenanted with the attention output
  
  Arguments
  ---------
  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]))
class_docstr_tok: ["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",":","input-",">","word","embedding","-",">","encoder","-",">","attention","-",">","decoder","(","+prenet",")","-",">","postnet","-",">","output","prenet","(","input","is","decoder","previous","time","step",")","output","is","input","to","decoder","concatenanted","with","the","attention","output","Arguments","--","--","--","--","-","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: Masks the padded part of output
  
  Arguments
  ---------
  outputs: list
      a list of tensors - raw outputs
  outputs_lengths: torch.Tensor
      a tensor representing the lengths of all outputs
  alignments_dim: int
      the desired dimension of the alignments along the last axis
      Optional but needed for data-parallel training
  
  
  Returns
  -------
  result: tuple
      a (mel_outputs, mel_outputs_postnet, gate_outputs, alignments) tuple with
      the original outputs - with the mask applied
docstr_tok: ["Masks","the","padded","part","of","output","Arguments","--","--","--","--","-","outputs",":","list","a","list","of","tensors","-","raw","outputs","outputs_lengths",":","torch.Tensor","a","tensor","representing","the","lengths","of","all","outputs","alignments_dim",":","int","the","desired","dimension","of","the","alignments","along","the","last","axis","Optional","but","needed","for","data-parallel","training","Returns","--","--","--","-","result",":","tuple","a","(","mel_outputs",",","mel_outputs_postnet",",","gate_outputs",",","alignments",")","tuple","with","the","original","outputs","-","with","the","mask","applied"]
code: def parse_output(self, outputs, output_lengths, alignments_dim=None):
      """
      Masks the padded part of output
  
      Arguments
      ---------
      outputs: list
          a list of tensors - raw outputs
      outputs_lengths: torch.Tensor
          a tensor representing the lengths of all outputs
      alignments_dim: int
          the desired dimension of the alignments along the last axis
          Optional but needed for data-parallel training
  
  
      Returns
      -------
      result: tuple
          a (mel_outputs, mel_outputs_postnet, gate_outputs, alignments) tuple with
          the original outputs - with the mask applied
      """
      (
          mel_outputs,
          mel_outputs_postnet,
          gate_outputs,
          alignments,
      ) = outputs
      if self.mask_padding and output_lengths is not None:
          mask = get_mask_from_lengths(
              output_lengths, max_len=mel_outputs.size(-1)
          )
          mask = mask.expand(
              self.n_mel_channels, mask.size(0), mask.size(1)
          )
          mask = mask.permute(1, 0, 2)
  
          mel_outputs.clone().masked_fill_(mask, 0.0)
          mel_outputs_postnet.masked_fill_(mask, 0.0)
          gate_outputs.masked_fill_(mask[:, 0, :], 1e3)  # gate energies
      if alignments_dim is not None:
          alignments = F.pad(
              alignments, (0, alignments_dim - alignments.size(-1))
          )
  
      return mel_outputs, mel_outputs_postnet, gate_outputs, alignments
  
imports: from math import sqrt
  from speechbrain.nnet.loss.guidedattn_loss import GuidedAttentionLoss
  from speechbrain.lobes.models.transformer.Transformer import get_mask_from_lengths
  import torch
  from torch import nn
  from torch.nn import functional
  from collections import namedtuple
label_desc: Use image node_id 2 for calling the Tacotron2 obj's underlying member method code with example usage: obj.parse_output(outputs, output_lengths, alignments_dim) and returns: mel_outputs,  mel_outputs_postnet,  gate_outputs,  alignments