class_docstr: The Tacotron decoder
  
  Arguments
  ---------
  n_mel_channels: int
      the number of channels in the MEL sepctrogram
  n_frames_per_step:
      the number of frames in the spectrogram for each
      time step of the decoder
  encoder_embedding_dim: int
      the dimension of the encoder embedding
  attention_location_n_filters: int
      the number of filters in location-based attention
  attention_location_kernel_size: int
      the kernel size of location-based attention
  attention_rnn_dim: int
      RNN dimension for the attention layer
  decoder_rnn_dim: int
      the encoder RNN dimension
  prenet_dim: int
      the dimension of the prenet (inner and output layers)
  max_decoder_steps: int
      the maximum number of decoder steps for the longest utterance
      expected for the model
  gate_threshold: float
      the fixed threshold to which the outputs of the decoders will be compared
  p_attention_dropout: float
      dropout probability for attention layers
  
  Example
  -------
  >>> import torch
  >>> from speechbrain.lobes.models.Tacotron2 import Decoder
  >>> layer = Decoder()
  >>> memory = torch.randn(2, 173, 512)
  >>> decoder_inputs = torch.randn(2, 80, 173)
  >>> memory_lengths = torch.tensor([173, 91])
  >>> mel_outputs, gate_outputs, alignments = layer(
  ...     memory, decoder_inputs, memory_lengths)
  >>> mel_outputs.shape, gate_outputs.shape, alignments.shape
  (torch.Size([2, 80, 173]), torch.Size([2, 173]), torch.Size([2, 173, 173]))
class_docstr_tok: ["The","Tacotron","decoder","Arguments","--","--","--","--","-","n_mel_channels",":","int","the","number","of","channels","in","the","MEL","sepctrogram","n_frames_per_step",":","the","number","of","frames","in","the","spectrogram","for","each","time","step","of","the","decoder","encoder_embedding_dim",":","int","the","dimension","of","the","encoder","embedding","attention_location_n_filters",":","int","the","number","of","filters","in","location-based","attention","attention_location_kernel_size",":","int","the","kernel","size","of","location-based","attention","attention_rnn_dim",":","int","RNN","dimension","for","the","attention","layer","decoder_rnn_dim",":","int","the","encoder","RNN","dimension","prenet_dim",":","int","the","dimension","of","the","prenet","(","inner","and","output","layers",")","max_decoder_steps",":","int","the","maximum","number","of","decoder","steps","for","the","longest","utterance","expected","for","the","model","gate_threshold",":","float","the","fixed","threshold","to","which","the","outputs","of","the","decoders","will","be","compared","p_attention_dropout",":","float","dropout","probability","for","attention","layers","Example","--","--","--","-",">",">",">","import","torch",">",">",">","from","speechbrain.lobes.models.Tacotron2","import","Decoder",">",">",">","layer","=","Decoder","(",")",">",">",">","memory","=","torch.randn","(","2",",","173",",","512",")",">",">",">","decoder_inputs","=","torch.randn","(","2",",","80",",","173",")",">",">",">","memory_lengths","=","torch.tensor","(","[","173",",","91","]",")",">",">",">","mel_outputs",",","gate_outputs",",","alignments","=","layer","(","...","memory",",","decoder_inputs",",","memory_lengths",")",">",">",">","mel_outputs.shape",",","gate_outputs.shape",",","alignments.shape","(","torch.Size","(","[","2",",","80",",","173","]",")",",","torch.Size","(","[","2",",","173","]",")",",","torch.Size","(","[","2",",","173",",","173","]",")",")"]
docstr: Initializes attention rnn states, decoder rnn states, attention
  weights, attention cumulative weights, attention context, stores memory
  and stores processed memory
  
  Arguments
  ---------
  memory: torch.Tensor
      Encoder outputs
  mask: torch.Tensor
      Mask for padded data if training, expects None for inference
  
  Returns
  -------
  result: tuple
      A tuple of tensors
      (
          attention_hidden,
          attention_cell,
          decoder_hidden,
          decoder_cell,
          attention_weights,
          attention_weights_cum,
          attention_context,
          processed_memory,
      )
docstr_tok: ["Initializes","attention","rnn","states",",","decoder","rnn","states",",","attention","weights",",","attention","cumulative","weights",",","attention","context",",","stores","memory","and","stores","processed","memory","Arguments","--","--","--","--","-","memory",":","torch.Tensor","Encoder","outputs","mask",":","torch.Tensor","Mask","for","padded","data","if","training",",","expects","None","for","inference","Returns","--","--","--","-","result",":","tuple","A","tuple","of","tensors","(","attention_hidden",",","attention_cell",",","decoder_hidden",",","decoder_cell",",","attention_weights",",","attention_weights_cum",",","attention_context",",","processed_memory",",",")"]
code: def initialize_decoder_states(self, memory):
      """Initializes attention rnn states, decoder rnn states, attention
      weights, attention cumulative weights, attention context, stores memory
      and stores processed memory
  
      Arguments
      ---------
      memory: torch.Tensor
          Encoder outputs
      mask: torch.Tensor
          Mask for padded data if training, expects None for inference
  
      Returns
      -------
      result: tuple
          A tuple of tensors
          (
              attention_hidden,
              attention_cell,
              decoder_hidden,
              decoder_cell,
              attention_weights,
              attention_weights_cum,
              attention_context,
              processed_memory,
          )
      """
      B = memory.size(0)
      MAX_TIME = memory.size(1)
      dtype = memory.dtype
      device = memory.device
  
      attention_hidden = torch.zeros(
          B, self.attention_rnn_dim, dtype=dtype, device=device
      )
      attention_cell = torch.zeros(
          B, self.attention_rnn_dim, dtype=dtype, device=device
      )
  
      decoder_hidden = torch.zeros(
          B, self.decoder_rnn_dim, dtype=dtype, device=device
      )
      decoder_cell = torch.zeros(
          B, self.decoder_rnn_dim, dtype=dtype, device=device
      )
  
      attention_weights = torch.zeros(
          B, MAX_TIME, dtype=dtype, device=device
      )
      attention_weights_cum = torch.zeros(
          B, MAX_TIME, dtype=dtype, device=device
      )
      attention_context = torch.zeros(
          B, 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: 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 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