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 = layers.LayerNormalization(epsilon=1e-5)
      self.layer_norm_masked_attention = layers.LayerNormalization(
          epsilon=1e-5
      )
      self.layer_norm_attention = layers.LayerNormalization(
          epsilon=1e-5
      )
      self.layer_norm_output = layers.LayerNormalization(epsilon=1e-5)
  
      self.dropout = layers.Dropout(rate=dropout)
      self.embed = layers.Embedding(vocab_size, d_model)
      self.positional_encoding = PositionalEncoding(
          d_model, dropout, maximum_position_encoding
      )
  
      self.attention = [
          MultiHeadAttention(num_heads, d_model, dropout)
          for _ in range(self.num_layers)
      ]
      self.source_attention = [
          MultiHeadAttention(num_heads, d_model, dropout)
          for _ in range(self.num_layers)
      ]
      self.position_feed_forward = [
          PositionwiseFeedForward(d_model, dff, dropout)
          for _ in range(self.num_layers)
      ]
  
imports: import math
  from typing import Any, Callable, Optional, Tuple
  import tensorflow
  from tensorflow.keras import layers
  from doctr.utils.repr import NestedObject
label_desc: Use image node_id 1 to create a new Decoder object from inherited base classes: layers, NestedObject with example: obj = Decoder(num_layers, num_heads, d_model, vocab_size, dropout, dff, maximum_position_encoding)