class_docstr: Decoder with Attention model.
  
  Args:
      n_mels (int): number of mel bins
      n_frames_per_step (int): number of frames processed per step, only 1 is supported
      encoder_embedding_dim (int): the number of embedding dimensions in the encoder.
      decoder_rnn_dim (int): number of units in decoder LSTM
      decoder_max_step (int): maximum number of output mel spectrograms
      decoder_dropout (float): dropout probability for decoder LSTM
      decoder_early_stopping (bool): stop decoding when all samples are finished
      attention_rnn_dim (int): number of units in attention LSTM
      attention_hidden_dim (int): dimension of attention hidden representation
      attention_location_n_filter (int): number of filters for attention model
      attention_location_kernel_size (int): kernel size for attention model
      attention_dropout (float): dropout probability for attention LSTM
      prenet_dim (int): number of ReLU units in prenet layers
      gate_threshold (float): probability threshold for stop token
class_docstr_tok: ["Decoder","with","Attention","model",".","Args",":","n_mels","(","int",")",":","number","of","mel","bins","n_frames_per_step","(","int",")",":","number","of","frames","processed","per","step",",","only","1","is","supported","encoder_embedding_dim","(","int",")",":","the","number","of","embedding","dimensions","in","the","encoder",".","decoder_rnn_dim","(","int",")",":","number","of","units","in","decoder","LSTM","decoder_max_step","(","int",")",":","maximum","number","of","output","mel","spectrograms","decoder_dropout","(","float",")",":","dropout","probability","for","decoder","LSTM","decoder_early_stopping","(","bool",")",":","stop","decoding","when","all","samples","are","finished","attention_rnn_dim","(","int",")",":","number","of","units","in","attention","LSTM","attention_hidden_dim","(","int",")",":","dimension","of","attention","hidden","representation","attention_location_n_filter","(","int",")",":","number","of","filters","for","attention","model","attention_location_kernel_size","(","int",")",":","kernel","size","for","attention","model","attention_dropout","(","float",")",":","dropout","probability","for","attention","LSTM","prenet_dim","(","int",")",":","number","of","ReLU","units","in","prenet","layers","gate_threshold","(","float",")",":","probability","threshold","for","stop","token"]
docstr: Decoder step using stored states, attention and memory
  
  Args:
      decoder_input (Tensor): Output of the Prenet with shape (n_batch, ``prenet_dim``).
      attention_hidden (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
      attention_cell (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
      decoder_hidden (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
      decoder_cell (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
      attention_weights (Tensor): Attention weights with shape (n_batch, max of ``text_lengths``).
      attention_weights_cum (Tensor): Cumulated attention weights with shape (n_batch, max of ``text_lengths``).
      attention_context (Tensor): Context vector with shape (n_batch, ``encoder_embedding_dim``).
      memory (Tensor): Encoder output with shape (n_batch, max of ``text_lengths``, ``encoder_embedding_dim``).
      processed_memory (Tensor): Processed Encoder outputs
          with shape (n_batch, max of ``text_lengths``, ``attention_hidden_dim``).
      mask (Tensor): Binary mask for padded data with shape (n_batch, current_num_frames).
  
  Returns:
      decoder_output: Predicted mel spectrogram for the current frame with shape (n_batch, ``n_mels``).
      gate_prediction (Tensor): Prediction of the stop token with shape (n_batch, ``1``).
      attention_hidden (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
      attention_cell (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
      decoder_hidden (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
      decoder_cell (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
      attention_weights (Tensor): Attention weights with shape (n_batch, max of ``text_lengths``).
      attention_weights_cum (Tensor): Cumulated attention weights with shape (n_batch, max of ``text_lengths``).
      attention_context (Tensor): Context vector with shape (n_batch, ``encoder_embedding_dim``).
docstr_tok: ["Decoder","step","using","stored","states",",","attention","and","memory","Args",":","decoder_input","(","Tensor",")",":","Output","of","the","Prenet","with","shape","(","n_batch",",","``","prenet_dim","``",")",".","attention_hidden","(","Tensor",")",":","Hidden","state","of","the","attention","LSTM","with","shape","(","n_batch",",","``","attention_rnn_dim","``",")",".","attention_cell","(","Tensor",")",":","Hidden","state","of","the","attention","LSTM","with","shape","(","n_batch",",","``","attention_rnn_dim","``",")",".","decoder_hidden","(","Tensor",")",":","Hidden","state","of","the","decoder","LSTM","with","shape","(","n_batch",",","``","decoder_rnn_dim","``",")",".","decoder_cell","(","Tensor",")",":","Hidden","state","of","the","decoder","LSTM","with","shape","(","n_batch",",","``","decoder_rnn_dim","``",")",".","attention_weights","(","Tensor",")",":","Attention","weights","with","shape","(","n_batch",",","max","of","``","text_lengths","``",")",".","attention_weights_cum","(","Tensor",")",":","Cumulated","attention","weights","with","shape","(","n_batch",",","max","of","``","text_lengths","``",")",".","attention_context","(","Tensor",")",":","Context","vector","with","shape","(","n_batch",",","``","encoder_embedding_dim","``",")",".","memory","(","Tensor",")",":","Encoder","output","with","shape","(","n_batch",",","max","of","``","text_lengths","``",",","``","encoder_embedding_dim","``",")",".","processed_memory","(","Tensor",")",":","Processed","Encoder","outputs","with","shape","(","n_batch",",","max","of","``","text_lengths","``",",","``","attention_hidden_dim","``",")",".","mask","(","Tensor",")",":","Binary","mask","for","padded","data","with","shape","(","n_batch",",","current_num_frames",")",".","Returns",":","decoder_output",":","Predicted","mel","spectrogram","for","the","current","frame","with","shape","(","n_batch",",","``","n_mels","``",")",".","gate_prediction","(","Tensor",")",":","Prediction","of","the","stop","token","with","shape","(","n_batch",",","``","1","``",")",".","attention_hidden","(","Tensor",")",":","Hidden","state","of","the","attention","LSTM","with","shape","(","n_batch",",","``","attention_rnn_dim","``",")",".","attention_cell","(","Tensor",")",":","Hidden","state","of","the","attention","LSTM","with","shape","(","n_batch",",","``","attention_rnn_dim","``",")",".","decoder_hidden","(","Tensor",")",":","Hidden","state","of","the","decoder","LSTM","with","shape","(","n_batch",",","``","decoder_rnn_dim","``",")",".","decoder_cell","(","Tensor",")",":","Hidden","state","of","the","decoder","LSTM","with","shape","(","n_batch",",","``","decoder_rnn_dim","``",")",".","attention_weights","(","Tensor",")",":","Attention","weights","with","shape","(","n_batch",",","max","of","``","text_lengths","``",")",".","attention_weights_cum","(","Tensor",")",":","Cumulated","attention","weights","with","shape","(","n_batch",",","max","of","``","text_lengths","``",")",".","attention_context","(","Tensor",")",":","Context","vector","with","shape","(","n_batch",",","``","encoder_embedding_dim","``",")","."]
code: def decode(
      self,
      decoder_input: Tensor,
      attention_hidden: Tensor,
      attention_cell: Tensor,
      decoder_hidden: Tensor,
      decoder_cell: Tensor,
      attention_weights: Tensor,
      attention_weights_cum: Tensor,
      attention_context: Tensor,
      memory: Tensor,
      processed_memory: Tensor,
      mask: Tensor,
  ) -> Tuple[
      Tensor,
      Tensor,
      Tensor,
      Tensor,
      Tensor,
      Tensor,
      Tensor,
      Tensor,
      Tensor,
  ]:
      r"""Decoder step using stored states, attention and memory
  
      Args:
          decoder_input (Tensor): Output of the Prenet with shape (n_batch, ``prenet_dim``).
          attention_hidden (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
          attention_cell (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
          decoder_hidden (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
          decoder_cell (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
          attention_weights (Tensor): Attention weights with shape (n_batch, max of ``text_lengths``).
          attention_weights_cum (Tensor): Cumulated attention weights with shape (n_batch, max of ``text_lengths``).
          attention_context (Tensor): Context vector with shape (n_batch, ``encoder_embedding_dim``).
          memory (Tensor): Encoder output with shape (n_batch, max of ``text_lengths``, ``encoder_embedding_dim``).
          processed_memory (Tensor): Processed Encoder outputs
              with shape (n_batch, max of ``text_lengths``, ``attention_hidden_dim``).
          mask (Tensor): Binary mask for padded data with shape (n_batch, current_num_frames).
  
      Returns:
          decoder_output: Predicted mel spectrogram for the current frame with shape (n_batch, ``n_mels``).
          gate_prediction (Tensor): Prediction of the stop token with shape (n_batch, ``1``).
          attention_hidden (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
          attention_cell (Tensor): Hidden state of the attention LSTM with shape (n_batch, ``attention_rnn_dim``).
          decoder_hidden (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
          decoder_cell (Tensor): Hidden state of the decoder LSTM with shape (n_batch, ``decoder_rnn_dim``).
          attention_weights (Tensor): Attention weights with shape (n_batch, max of ``text_lengths``).
          attention_weights_cum (Tensor): Cumulated attention weights with shape (n_batch, max of ``text_lengths``).
          attention_context (Tensor): Context vector with shape (n_batch, ``encoder_embedding_dim``).
      """
      cell_input = torch.cat((decoder_input, attention_context), -1)
  
      attention_hidden, attention_cell = self.attention_rnn(
          cell_input, (attention_hidden, attention_cell)
      )
      attention_hidden = F.dropout(
          attention_hidden, self.attention_dropout, self.training
      )
  
      attention_weights_cat = torch.cat(
          (
              attention_weights.unsqueeze(1),
              attention_weights_cum.unsqueeze(1),
          ),
          dim=1,
      )
      attention_context, attention_weights = self.attention_layer(
          attention_hidden,
          memory,
          processed_memory,
          attention_weights_cat,
          mask,
      )
  
      attention_weights_cum += attention_weights
      decoder_input = torch.cat(
          (attention_hidden, attention_context), -1
      )
  
      decoder_hidden, decoder_cell = self.decoder_rnn(
          decoder_input, (decoder_hidden, decoder_cell)
      )
      decoder_hidden = F.dropout(
          decoder_hidden, self.decoder_dropout, self.training
      )
  
      decoder_hidden_attention_context = torch.cat(
          (decoder_hidden, attention_context), dim=1
      )
      decoder_output = self.linear_projection(
          decoder_hidden_attention_context
      )
  
      gate_prediction = self.gate_layer(
          decoder_hidden_attention_context
      )
  
      return (
          decoder_output,
          gate_prediction,
          attention_hidden,
          attention_cell,
          decoder_hidden,
          decoder_cell,
          attention_weights,
          attention_weights_cum,
          attention_context,
      )
  
imports: import warnings
  from typing import List, Optional, Tuple, Union
  import torch
  from torch import nn, Tensor
  from torch.nn import functional
label_desc: Use image node_id 6 for calling the _Decoder obj's underlying member method code with example usage: obj.decode(decoder_input, attention_hidden, attention_cell, decoder_hidden, decoder_cell, attention_weights, attention_weights_cum, attention_context, memory, processed_memory, mask) and returns: decoder_output,  gate_prediction,  attention_hidden,  attention_cell,  decoder_hidden,  decoder_cell,  attention_weights,  attention_weights_cum,  attention_context