class_docstr: Tacotron2 decoder. We don't use Zoneout but Dropout between RNN layers.
  
  Args:
      in_channels (int): number of input channels.
      frame_channels (int): number of feature frame channels.
      r (int): number of outputs per time step (reduction rate).
      memory_size (int): size of the past window. if <= 0 memory_size = r
      attn_type (string): type of attention used in decoder.
      attn_win (bool): if true, define an attention window centered to maximum
          attention response. It provides more robust attention alignment especially
          at interence time.
      attn_norm (string): attention normalization function. 'sigmoid' or 'softmax'.
      prenet_type (string): 'original' or 'bn'.
      prenet_dropout (float): prenet dropout rate.
      forward_attn (bool): if true, use forward attention method. https://arxiv.org/abs/1807.06736
      trans_agent (bool): if true, use transition agent. https://arxiv.org/abs/1807.06736
      forward_attn_mask (bool): if true, mask attention values smaller than a threshold.
      location_attn (bool): if true, use location sensitive attention.
      attn_K (int): number of attention heads for GravesAttention.
      separate_stopnet (bool): if true, detach stopnet input to prevent gradient flow.
code: def __init__(
      self,
      in_channels,
      frame_channels,
      r,
      attn_type,
      attn_win,
      attn_norm,
      prenet_type,
      prenet_dropout,
      forward_attn,
      trans_agent,
      forward_attn_mask,
      location_attn,
      attn_K,
      separate_stopnet,
  ):
      super(Decoder, self).__init__()
      self.frame_channels = frame_channels
      self.r_init = r
      self.r = r
      self.encoder_embedding_dim = in_channels
      self.separate_stopnet = separate_stopnet
      self.max_decoder_steps = 1000
      self.stop_threshold = 0.5
  
      # model dimensions
      self.query_dim = 1024
      self.decoder_rnn_dim = 1024
      self.prenet_dim = 256
      self.attn_dim = 128
      self.p_attention_dropout = 0.1
      self.p_decoder_dropout = 0.1
  
      # memory -> |Prenet| -> processed_memory
      prenet_dim = self.frame_channels
      self.prenet = Prenet(
          prenet_dim,
          prenet_type,
          prenet_dropout,
          out_features=[self.prenet_dim, self.prenet_dim],
          bias=False,
      )
  
      self.attention_rnn = nn.LSTMCell(
          self.prenet_dim + in_channels, self.query_dim, bias=True
      )
  
      self.attention = init_attn(
          attn_type=attn_type,
          query_dim=self.query_dim,
          embedding_dim=in_channels,
          attention_dim=128,
          location_attention=location_attn,
          attention_location_n_filters=32,
          attention_location_kernel_size=31,
          windowing=attn_win,
          norm=attn_norm,
          forward_attn=forward_attn,
          trans_agent=trans_agent,
          forward_attn_mask=forward_attn_mask,
          attn_K=attn_K,
      )
  
      self.decoder_rnn = nn.LSTMCell(
          self.query_dim + in_channels, self.decoder_rnn_dim, bias=True
      )
  
      self.linear_projection = Linear(
          self.decoder_rnn_dim + in_channels,
          self.frame_channels * self.r_init,
      )
  
      self.stopnet = nn.Sequential(
          nn.Dropout(0.1),
          Linear(
              self.decoder_rnn_dim + self.frame_channels * self.r_init,
              1,
              bias=True,
              init_gain="sigmoid",
          ),
      )
      self.memory_truncated = None
  
imports: import torch
  from torch import nn
  from torch.nn import functional
  from .common_layers import Prenet, Linear
  from .attentions import init_attn
label_desc: Use image node_id 1 to create a new Decoder object from inherited base classes: nn with example: obj = Decoder(in_channels, frame_channels, r, attn_type, attn_win, attn_norm, prenet_type, prenet_dropout, forward_attn, trans_agent, forward_attn_mask, location_attn, attn_K, separate_stopnet)