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] = nn.ReLU(),
  ) -> None:
      super().__init__()
  
      self.num_layers = num_layers
  
      self.layer_norm_input = 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.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, activation_fct
              )
              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 EncoderBlock object from inherited base classes: nn with example: obj = EncoderBlock(num_layers, num_heads, d_model, dff, dropout, activation_fct)