docstr: Tacotron 2 Decoder. Consists of a 2 layer LSTM, one of which interfaces with the attention mechanism while the
  other is used as a regular LSTM. Includes the prenet and attention modules as well.
  
  Args:
      n_mel_channels (int): Number of mel channels to output
      n_frames_per_step (int): Number of spectrogram frames to predict per decoder step.
      encoder_embedding_dim (int): The size of the output from the encoder.
      attention_dim (int): The output dimension of the attention layer.
      attention_location_n_filters (int): Channel size for the convolution used the attention mechanism.
      attention_location_kernel_size (int): Kernel size for the convolution used the attention mechanism.
      attention_rnn_dim (int): The output dimension of the attention LSTM layer.
      decoder_rnn_dim (int): The output dimension of the second LSTM layer.
      prenet_dim (int): The output dimension of the prenet.
      max_decoder_steps (int): For evaluation, the max number of steps to predict.
      gate_threshold (float): At each step, tacotron 2 predicts a probability of stopping. Rather than sampling,
          this module checks if predicted probability is above the gate_threshold. Only in evaluation.
      p_attention_dropout (float): Dropout probability on the attention LSTM.
      p_decoder_dropout (float): Dropout probability on the second LSTM.
      early_stopping (bool): In evaluation mode, whether to stop when all batches hit the gate_threshold or to
          continue until max_decoder_steps.
      prenet_p_dropout (float): Dropout probability for prenet. Note, dropout is on even in eval() mode.
          Defaults to 0.5.
docstr_tok: ["Tacotron","2","Decoder",".","Consists","of","a","2","layer","LSTM",",","one","of","which","interfaces","with","the","attention","mechanism","while","the","other","is","used","as","a","regular","LSTM",".","Includes","the","prenet","and","attention","modules","as","well",".","Args",":","n_mel_channels","(","int",")",":","Number","of","mel","channels","to","output","n_frames_per_step","(","int",")",":","Number","of","spectrogram","frames","to","predict","per","decoder","step",".","encoder_embedding_dim","(","int",")",":","The","size","of","the","output","from","the","encoder",".","attention_dim","(","int",")",":","The","output","dimension","of","the","attention","layer",".","attention_location_n_filters","(","int",")",":","Channel","size","for","the","convolution","used","the","attention","mechanism",".","attention_location_kernel_size","(","int",")",":","Kernel","size","for","the","convolution","used","the","attention","mechanism",".","attention_rnn_dim","(","int",")",":","The","output","dimension","of","the","attention","LSTM","layer",".","decoder_rnn_dim","(","int",")",":","The","output","dimension","of","the","second","LSTM","layer",".","prenet_dim","(","int",")",":","The","output","dimension","of","the","prenet",".","max_decoder_steps","(","int",")",":","For","evaluation",",","the","max","number","of","steps","to","predict",".","gate_threshold","(","float",")",":","At","each","step",",","tacotron","2","predicts","a","probability","of","stopping",".","Rather","than","sampling",",","this","module","checks","if","predicted","probability","is","above","the","gate_threshold",".","Only","in","evaluation",".","p_attention_dropout","(","float",")",":","Dropout","probability","on","the","attention","LSTM",".","p_decoder_dropout","(","float",")",":","Dropout","probability","on","the","second","LSTM",".","early_stopping","(","bool",")",":","In","evaluation","mode",",","whether","to","stop","when","all","batches","hit","the","gate_threshold","or","to","continue","until","max_decoder_steps",".","prenet_p_dropout","(","float",")",":","Dropout","probability","for","prenet",".","Note",",","dropout","is","on","even","in","eval","(",")","mode",".","Defaults","to","0.5","."]
code: def __init__(
      self,
      n_mel_channels: int,
      n_frames_per_step: int,
      encoder_embedding_dim: int,
      attention_dim: int,
      attention_location_n_filters: int,
      attention_location_kernel_size: int,
      attention_rnn_dim: int,
      decoder_rnn_dim: int,
      prenet_dim: int,
      max_decoder_steps: int,
      gate_threshold: float,
      p_attention_dropout: float,
      p_decoder_dropout: float,
      early_stopping: bool,
      prenet_p_dropout: float = 0.5,
  ):
      """
      Tacotron 2 Decoder. Consists of a 2 layer LSTM, one of which interfaces with the attention mechanism while the
      other is used as a regular LSTM. Includes the prenet and attention modules as well.
  
      Args:
          n_mel_channels (int): Number of mel channels to output
          n_frames_per_step (int): Number of spectrogram frames to predict per decoder step.
          encoder_embedding_dim (int): The size of the output from the encoder.
          attention_dim (int): The output dimension of the attention layer.
          attention_location_n_filters (int): Channel size for the convolution used the attention mechanism.
          attention_location_kernel_size (int): Kernel size for the convolution used the attention mechanism.
          attention_rnn_dim (int): The output dimension of the attention LSTM layer.
          decoder_rnn_dim (int): The output dimension of the second LSTM layer.
          prenet_dim (int): The output dimension of the prenet.
          max_decoder_steps (int): For evaluation, the max number of steps to predict.
          gate_threshold (float): At each step, tacotron 2 predicts a probability of stopping. Rather than sampling,
              this module checks if predicted probability is above the gate_threshold. Only in evaluation.
          p_attention_dropout (float): Dropout probability on the attention LSTM.
          p_decoder_dropout (float): Dropout probability on the second LSTM.
          early_stopping (bool): In evaluation mode, whether to stop when all batches hit the gate_threshold or to
              continue until max_decoder_steps.
          prenet_p_dropout (float): Dropout probability for prenet. Note, dropout is on even in eval() mode.
              Defaults to 0.5.
      """
      super().__init__()
      self.n_mel_channels = n_mel_channels
      self.n_frames_per_step = n_frames_per_step
      self.encoder_embedding_dim = encoder_embedding_dim
      self.attention_rnn_dim = attention_rnn_dim
      self.decoder_rnn_dim = decoder_rnn_dim
      self.prenet_dim = prenet_dim
      self.max_decoder_steps = max_decoder_steps
      self.gate_threshold = gate_threshold
      self.p_attention_dropout = p_attention_dropout
      self.p_decoder_dropout = p_decoder_dropout
      self.early_stopping = early_stopping
  
      self.prenet = Prenet(
          n_mel_channels * n_frames_per_step,
          [prenet_dim, prenet_dim],
          prenet_p_dropout,
      )
  
      self.attention_rnn = torch.nn.LSTMCell(
          prenet_dim + encoder_embedding_dim, attention_rnn_dim
      )
  
      self.attention_layer = Attention(
          attention_rnn_dim,
          encoder_embedding_dim,
          attention_dim,
          attention_location_n_filters,
          attention_location_kernel_size,
      )
  
      self.decoder_rnn = torch.nn.LSTMCell(
          attention_rnn_dim + encoder_embedding_dim, decoder_rnn_dim, 1
      )
  
      self.linear_projection = LinearNorm(
          decoder_rnn_dim + encoder_embedding_dim,
          n_mel_channels * n_frames_per_step,
      )
  
      self.gate_layer = LinearNorm(
          decoder_rnn_dim + encoder_embedding_dim,
          1,
          bias=True,
          w_init_gain="sigmoid",
      )
  
imports: import torch
  from torch.autograd import Variable
  from torch.nn import functional
  from nemo.collections.tts.modules.submodules import Attention, ConvNorm, LinearNorm, Prenet
  from nemo.collections.tts.parts.utils.helpers import get_mask_from_lengths
  from nemo.core.classes import NeuralModule, typecheck
  from nemo.core.neural_types.elements import EmbeddedTextType, LengthsType, LogitsType, MelSpectrogramType, SequenceToSequenceAlignmentType
  from nemo.core.neural_types.neural_type import NeuralType
  from nemo.utils import logging
label_desc: Use image node_id 1 to create a new Decoder object from inherited base classes: NeuralModule with example: obj = Decoder(n_mel_channels, n_frames_per_step, encoder_embedding_dim, attention_dim, attention_location_n_filters, attention_location_kernel_size, attention_rnn_dim, decoder_rnn_dim, prenet_dim, max_decoder_steps, gate_threshold, p_attention_dropout, p_decoder_dropout, early_stopping, prenet_p_dropout)