class_docstr: Transformer Decoder
class_docstr_tok: ["Transformer","Decoder"]
code: def __init__(
      self,
      num_layers: int,
      num_heads: int,
      d_model: int,
      vocab_size: int,
      dropout: float = 0.2,
      dff: int = 2048,  # hidden dimension of the feedforward network
      maximum_position_encoding: int = 50,
  ) -> None:
      super(Decoder, self).__init__()
      self.num_layers = num_layers
      self.d_model = d_model
  
      self.layer_norm_input = nn.LayerNorm(d_model, eps=1e-5)
      self.layer_norm_masked_attention = nn.LayerNorm(d_model, eps=1e-5)
      self.layer_norm_attention = nn.LayerNorm(d_model, eps=1e-5)
      self.layer_norm_output = nn.LayerNorm(d_model, eps=1e-5)
  
      self.dropout = nn.Dropout(dropout)
      self.embed = nn.Embedding(vocab_size, d_model)
      self.positional_encoding = PositionalEncoding(
          d_model, dropout, maximum_position_encoding
      )
  
      self.attention = nn.ModuleList(
          [
              MultiHeadAttention(num_heads, d_model, dropout)
              for _ in range(self.num_layers)
          ]
      )
      self.source_attention = nn.ModuleList(
          [
              MultiHeadAttention(num_heads, d_model, dropout)
              for _ in range(self.num_layers)
          ]
      )
      self.position_feed_forward = nn.ModuleList(
          [
              PositionwiseFeedForward(d_model, dff, dropout)
              for _ in range(self.num_layers)
          ]
      )
  
imports: import math
  from typing import Any, Callable, Optional, Tuple
  import torch
  from torch import nn
label_desc: Use image node_id 1 to create a new Decoder object from inherited base classes: nn with example: obj = Decoder(num_layers, num_heads, d_model, vocab_size, dropout, dff, maximum_position_encoding)