class_docstr: Multi-head attention + FC + Layer-norm + Dropout.
  
  Similar to PyTorch's ``nn.TransformerEncoderLayer`` but supports :class:`RelativePositionSelfAttention`.
  
  Parameters
  ----------
  embed_dim
      Embedding dimension.
  num_heads
      Number of attention heads.
  mlp_ratio
      Ratio of MLP hidden dim to embedding dim.
  drop_path
      Drop path rate.
  drop_rate
      Dropout rate.
  pre_norm
      Whether to apply layer norm before attention.
  **kwargs
      Other arguments for :class:`RelativePositionSelfAttention`.
code: def __init__(
      self,
      embed_dim: int | Categorical[int],
      num_heads: int | Categorical[int],
      mlp_ratio: int
      | float
      | Categorical[int]
      | Categorical[float] = 4.0,
      drop_path: float = 0.0,
      drop_rate: float = 0.0,
      pre_norm: bool = True,
      **kwargs,
  ):
      super().__init__()
  
      self.normalize_before = pre_norm
  
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.attn = RelativePositionSelfAttention(
          embed_dim=embed_dim, num_heads=num_heads, **kwargs
      )
  
      self.attn_layer_norm = MutableLayerNorm(cast(int, embed_dim))
      self.ffn_layer_norm = MutableLayerNorm(cast(int, embed_dim))
  
      self.activation_fn = nn.GELU()
  
      self.dropout = nn.Dropout(drop_rate)
  
      self.fc1 = MutableLinear(
          cast(int, embed_dim),
          cast(int, MutableExpression.to_int(embed_dim * mlp_ratio)),
      )
      self.fc2 = MutableLinear(
          cast(int, MutableExpression.to_int(embed_dim * mlp_ratio)),
          cast(int, embed_dim),
      )
  
imports: from __future__ import annotations
  from typing import Tuple, cast, Any, Dict
  import torch
  import torch.nn
  import torch.nn.functional
  import nni
  from nni.mutable import Categorical, MutableExpression, frozen_context, ensure_frozen, Mutable
  from nni.nas.nn.pytorch import ParametrizedModule, ModelSpace, MutableModule, Repeat, MutableConv2d, MutableLinear, MutableLayerNorm
  from nni.nas.space import current_model
  from nni.nas.oneshot.pytorch.supermodule.operation import MixedOperation
  from nni.nas.profiler.pytorch.flops import FlopsResult
  from nni.nas.profiler.pytorch.utils import MutableShape, ShapeTensor, profiler_leaf_module
  from .utils.pretrained import load_pretrained_weight
  from .utils.nn import DropPath
label_desc: Use image node_id 1 to create a new TransformerEncoderLayer object from inherited base classes: nn with example: obj = TransformerEncoderLayer(embed_dim, num_heads, mlp_ratio, drop_path, drop_rate, pre_norm)