class_docstr: Tacotron decoder.
  
  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_windowing (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.
      d_vector_dim (int): size of speaker embedding vector, for multi-speaker training.
      max_decoder_steps (int): Maximum number of steps allowed for the decoder. Defaults to 500.
class_docstr_tok: ["Tacotron","decoder",".","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_windowing","(","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",".","d_vector_dim","(","int",")",":","size","of","speaker","embedding","vector",",","for","multi-speaker","training",".","max_decoder_steps","(","int",")",":","Maximum","number","of","steps","allowed","for","the","decoder",".","Defaults","to","500","."]
code: def __init__(
      self,
      in_channels,
      frame_channels,
      r,
      memory_size,
      attn_type,
      attn_windowing,
      attn_norm,
      prenet_type,
      prenet_dropout,
      forward_attn,
      trans_agent,
      forward_attn_mask,
      location_attn,
      attn_K,
      separate_stopnet,
      max_decoder_steps,
  ):
      super().__init__()
      self.r_init = r
      self.r = r
      self.in_channels = in_channels
      self.max_decoder_steps = max_decoder_steps
      self.use_memory_queue = memory_size > 0
      self.memory_size = memory_size if memory_size > 0 else r
      self.frame_channels = frame_channels
      self.separate_stopnet = separate_stopnet
      self.query_dim = 256
      # memory -> |Prenet| -> processed_memory
      prenet_dim = (
          frame_channels * self.memory_size
          if self.use_memory_queue
          else frame_channels
      )
      self.prenet = Prenet(
          prenet_dim,
          prenet_type,
          prenet_dropout,
          out_features=[256, 128],
      )
      # processed_inputs, processed_memory -> |Attention| -> Attention, attention, RNN_State
      # attention_rnn generates queries for the attention mechanism
      self.attention_rnn = nn.GRUCell(in_channels + 128, self.query_dim)
      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_windowing,
          norm=attn_norm,
          forward_attn=forward_attn,
          trans_agent=trans_agent,
          forward_attn_mask=forward_attn_mask,
          attn_K=attn_K,
      )
      # (processed_memory | attention context) -> |Linear| -> decoder_RNN_input
      self.project_to_decoder_in = nn.Linear(256 + in_channels, 256)
      # decoder_RNN_input -> |RNN| -> RNN_state
      self.decoder_rnns = nn.ModuleList(
          [nn.GRUCell(256, 256) for _ in range(2)]
      )
      # RNN_state -> |Linear| -> mel_spec
      self.proj_to_mel = nn.Linear(256, frame_channels * self.r_init)
      # learn init values instead of zero init.
      self.stopnet = StopNet(256 + frame_channels * self.r_init)
  
imports: import torch
  from torch import nn
  from .attentions import init_attn
  from .common_layers import Prenet
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, memory_size, attn_type, attn_windowing, attn_norm, prenet_type, prenet_dropout, forward_attn, trans_agent, forward_attn_mask, location_attn, attn_K, separate_stopnet, max_decoder_steps)