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: Initializes attention rnn states, decoder rnn states, attention
  weights, attention cumulative weights, attention context, stores memory
  and stores processed memory.
  
  Args:
      memory (Tensor): Encoder outputs with shape (n_batch, max of ``text_lengths``, ``encoder_embedding_dim``).
  
  Returns:
      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``).
      processed_memory (Tensor): Processed encoder outputs
          with shape (n_batch, max of ``text_lengths``, ``attention_hidden_dim``).
docstr_tok: ["Initializes","attention","rnn","states",",","decoder","rnn","states",",","attention","weights",",","attention","cumulative","weights",",","attention","context",",","stores","memory","and","stores","processed","memory",".","Args",":","memory","(","Tensor",")",":","Encoder","outputs","with","shape","(","n_batch",",","max","of","``","text_lengths","``",",","``","encoder_embedding_dim","``",")",".","Returns",":","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","``",")",".","processed_memory","(","Tensor",")",":","Processed","encoder","outputs","with","shape","(","n_batch",",","max","of","``","text_lengths","``",",","``","attention_hidden_dim","``",")","."]
code: def _initialize_decoder_states(
      self, memory: Tensor
  ) -> Tuple[
      Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor, Tensor
  ]:
      r"""Initializes attention rnn states, decoder rnn states, attention
      weights, attention cumulative weights, attention context, stores memory
      and stores processed memory.
  
      Args:
          memory (Tensor): Encoder outputs with shape (n_batch, max of ``text_lengths``, ``encoder_embedding_dim``).
  
      Returns:
          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``).
          processed_memory (Tensor): Processed encoder outputs
              with shape (n_batch, max of ``text_lengths``, ``attention_hidden_dim``).
      """
      n_batch = memory.size(0)
      max_time = memory.size(1)
      dtype = memory.dtype
      device = memory.device
  
      attention_hidden = torch.zeros(
          n_batch, self.attention_rnn_dim, dtype=dtype, device=device
      )
      attention_cell = torch.zeros(
          n_batch, self.attention_rnn_dim, dtype=dtype, device=device
      )
  
      decoder_hidden = torch.zeros(
          n_batch, self.decoder_rnn_dim, dtype=dtype, device=device
      )
      decoder_cell = torch.zeros(
          n_batch, self.decoder_rnn_dim, dtype=dtype, device=device
      )
  
      attention_weights = torch.zeros(
          n_batch, max_time, dtype=dtype, device=device
      )
      attention_weights_cum = torch.zeros(
          n_batch, max_time, dtype=dtype, device=device
      )
      attention_context = torch.zeros(
          n_batch,
          self.encoder_embedding_dim,
          dtype=dtype,
          device=device,
      )
  
      processed_memory = self.attention_layer.memory_layer(memory)
  
      return (
          attention_hidden,
          attention_cell,
          decoder_hidden,
          decoder_cell,
          attention_weights,
          attention_weights_cum,
          attention_context,
          processed_memory,
      )
  
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 3 for calling the _Decoder obj's underlying member method code with example usage: obj._initialize_decoder_states(memory) and returns: attention_hidden,  attention_cell,  decoder_hidden,  decoder_cell,  attention_weights,  attention_weights_cum,  attention_context,  processed_memory