class_docstr: Transformer encoder block.
class_docstr_tok: ["Transformer","encoder","block","."]
code: def __init__(
      self,
      num_heads: int,
      hidden_dim: int,
      mlp_dim: int,
      dropout: float,
      attention_dropout: float,
      norm_layer: Callable[..., torch.nn.Module] = partial(
          nn.LayerNorm, eps=1e-6
      ),
  ):
      super().__init__()
      self.num_heads = num_heads
  
      # Attention block
      self.ln_1 = norm_layer(hidden_dim)
      self.self_attention = nn.MultiheadAttention(
          hidden_dim,
          num_heads,
          dropout=attention_dropout,
          batch_first=True,
      )
      self.dropout = nn.Dropout(dropout)
  
      # MLP block
      self.ln_2 = norm_layer(hidden_dim)
      self.mlp = MLPBlock(hidden_dim, mlp_dim, dropout)
  
imports: import math
  from collections import OrderedDict
  from functools import partial
  from typing import Any, Callable, Dict, List, NamedTuple, Optional
  import torch
  import torch.nn
  from ..ops.misc import Conv2dNormActivation, MLP
  from ..transforms._presets import ImageClassification, InterpolationMode
  from ..utils import _log_api_usage_once
  from ._api import register_model, Weights, WeightsEnum
  from ._meta import _IMAGENET_CATEGORIES
  from ._utils import _ovewrite_named_param, handle_legacy_interface
label_desc: Use image node_id 1 to create a new EncoderBlock object from inherited base classes: nn with example: obj = EncoderBlock(num_heads, hidden_dim, mlp_dim, dropout, attention_dropout, norm_layer)