class_docstr: Transformer Encoder Block
class_docstr_tok: ["Transformer","Encoder","Block"]
code: def __init__(
      self,
      num_layers: int,
      num_heads: int,
      d_model: int,
      dff: int,  # hidden dimension of the feedforward network
      dropout: float,
      activation_fct: Callable[[Any], Any] = layers.ReLU(),
  ) -> None:
      super().__init__()
  
      self.num_layers = num_layers
  
      self.layer_norm_input = 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.attention = [
          MultiHeadAttention(num_heads, d_model, dropout)
          for _ in range(self.num_layers)
      ]
      self.position_feed_forward = [
          PositionwiseFeedForward(d_model, dff, dropout, activation_fct)
          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 EncoderBlock object from inherited base classes: layers, NestedObject with example: obj = EncoderBlock(num_layers, num_heads, d_model, dff, dropout, activation_fct)