class_docstr: Transformer Model Encoder for sequence to sequence translation.
class_docstr_tok: ["Transformer","Model","Encoder","for","sequence","to","sequence","translation","."]
code: def __init__(
      self,
      seq_length: int,
      num_layers: int,
      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__()
      # Note that batch_size is on the first dim because
      # we have batch_first=True in nn.MultiAttention() by default
      self.pos_embedding = nn.Parameter(
          torch.empty(1, seq_length, hidden_dim).normal_(std=0.02)
      )  # from BERT
      self.dropout = nn.Dropout(dropout)
      layers: OrderedDict[str, nn.Module] = OrderedDict()
      for i in range(num_layers):
          layers[f"encoder_layer_{i}"] = EncoderBlock(
              num_heads,
              hidden_dim,
              mlp_dim,
              dropout,
              attention_dropout,
              norm_layer,
          )
      self.layers = nn.Sequential(layers)
      self.ln = norm_layer(hidden_dim)
  
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 Encoder object from inherited base classes: nn with example: obj = Encoder(seq_length, num_layers, num_heads, hidden_dim, mlp_dim, dropout, attention_dropout, norm_layer)