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: Decoder step using stored states, attention and memory
  Arguments
  ---------
  decoder_input: torch.Tensor
      previous mel output
  attention_hidden: torch.Tensor
      the hidden state of the attention module
  attention_cell: torch.Tensor
      the attention cell state
  decoder_hidden: torch.Tensor
      the decoder hidden state
  decoder_cell: torch.Tensor
      the decoder cell state
  attention_weights: torch.Tensor
      the attention weights
  attention_weights_cum: torch.Tensor
      cumulative attention weights
  attention_context: torch.Tensor
      the attention context tensor
  memory: torch.Tensor
      the memory tensor
  processed_memory: torch.Tensor
      the processed memory tensor
  mask: torch.Tensor
  
  
  
  Returns
  -------
  mel_output: torch.Tensor
      the MEL-scale outputs
  gate_output: torch.Tensor
      gate output energies
  attention_weights: torch.Tensor
      attention weights
docstr_tok: ["Decoder","step","using","stored","states",",","attention","and","memory","Arguments","--","--","--","--","-","decoder_input",":","torch.Tensor","previous","mel","output","attention_hidden",":","torch.Tensor","the","hidden","state","of","the","attention","module","attention_cell",":","torch.Tensor","the","attention","cell","state","decoder_hidden",":","torch.Tensor","the","decoder","hidden","state","decoder_cell",":","torch.Tensor","the","decoder","cell","state","attention_weights",":","torch.Tensor","the","attention","weights","attention_weights_cum",":","torch.Tensor","cumulative","attention","weights","attention_context",":","torch.Tensor","the","attention","context","tensor","memory",":","torch.Tensor","the","memory","tensor","processed_memory",":","torch.Tensor","the","processed","memory","tensor","mask",":","torch.Tensor","Returns","--","--","--","-","mel_output",":","torch.Tensor","the","MEL-scale","outputs","gate_output",":","torch.Tensor","gate","output","energies","attention_weights",":","torch.Tensor","attention","weights"]
code: def decode(
      self,
      decoder_input,
      attention_hidden,
      attention_cell,
      decoder_hidden,
      decoder_cell,
      attention_weights,
      attention_weights_cum,
      attention_context,
      memory,
      processed_memory,
      mask,
  ):
      """Decoder step using stored states, attention and memory
      Arguments
      ---------
      decoder_input: torch.Tensor
          previous mel output
      attention_hidden: torch.Tensor
          the hidden state of the attention module
      attention_cell: torch.Tensor
          the attention cell state
      decoder_hidden: torch.Tensor
          the decoder hidden state
      decoder_cell: torch.Tensor
          the decoder cell state
      attention_weights: torch.Tensor
          the attention weights
      attention_weights_cum: torch.Tensor
          cumulative attention weights
      attention_context: torch.Tensor
          the attention context tensor
      memory: torch.Tensor
          the memory tensor
      processed_memory: torch.Tensor
          the processed memory tensor
      mask: torch.Tensor
  
  
  
      Returns
      -------
      mel_output: torch.Tensor
          the MEL-scale outputs
      gate_output: torch.Tensor
          gate output energies
      attention_weights: torch.Tensor
          attention weights
      """
      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.p_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.p_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: 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 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