class_docstr: Represents a Transformer encoder as described in
  :cite:t:`https://doi.org/10.48550/arxiv.1706.03762`.
class_docstr_tok: ["Represents","a","Transformer","encoder","as","described","in",":","cite",":","t",":","`","https",":","\/\/doi.org\/10.48550\/arxiv.1706.03762","`","."]
docstr: :param layers:
      The encoder layers.
  :param self_attn_mask_factory:
      The self attention mask factory.
  :param layer_drop_p:
      If greater than zero, applies LayerDrop to the encoder layers as
      described in :cite:t:`https://doi.org/10.48550/arxiv.1909.11556`.
  :param norm_order:
      The Layer Normalization order.
  :param layer_norm_factory:
      The factory to construct the Layer Normalization module.
docstr_tok: [":","param","layers",":","The","encoder","layers",".",":","param","self_attn_mask_factory",":","The","self","attention","mask","factory",".",":","param","layer_drop_p",":","If","greater","than","zero",",","applies","LayerDrop","to","the","encoder","layers","as","described","in",":","cite",":","t",":","`","https",":","\/\/doi.org\/10.48550\/arxiv.1909.11556","`",".",":","param","norm_order",":","The","Layer","Normalization","order",".",":","param","layer_norm_factory",":","The","factory","to","construct","the","Layer","Normalization","module","."]
code: def __init__(
      self,
      layers: Iterable[TransformerEncoderLayer],
      *,
      self_attn_mask_factory: Optional[AttentionMaskFactory] = None,
      layer_drop_p: float = 0.0,
      norm_order: TransformerNormOrder = TransformerNormOrder.POST,
      layer_norm_factory: Optional[LayerNormFactory] = None,
      device: Optional[Device] = None,
      dtype: Optional[DataType] = None,
  ) -> None:
      """
      :param layers:
          The encoder layers.
      :param self_attn_mask_factory:
          The self attention mask factory.
      :param layer_drop_p:
          If greater than zero, applies LayerDrop to the encoder layers as
          described in :cite:t:`https://doi.org/10.48550/arxiv.1909.11556`.
      :param norm_order:
          The Layer Normalization order.
      :param layer_norm_factory:
          The factory to construct the Layer Normalization module.
      """
      layer_list = ModuleList(layers, drop_p=layer_drop_p)
      if not layer_list:
          raise ValueError("`layers` must be non-empty.")
  
      model_dim = layer_list[0].model_dim
  
      super().__init__(model_dim)
  
      if layer_norm_factory is None:
          layer_norm_factory = create_standard_layer_norm
  
      self.self_attn_mask_factory = self_attn_mask_factory
  
      self.layers = layer_list
  
      if norm_order != TransformerNormOrder.POST:
          self.layer_norm = layer_norm_factory(
              model_dim, device=device, dtype=dtype
          )
      else:
          self.register_module("layer_norm", None)
  
      self.norm_order = norm_order
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from typing import Dict, Iterable, Optional, Protocol, Tuple, final
  from torch import Tensor
  from torch.nn import Module
  from torch.utils.hooks import RemovableHandle
  from fairseq2.nn.module_list import ModuleList
  from fairseq2.nn.normalization import LayerNorm
  from fairseq2.nn.padding import PaddingMask
  from fairseq2.nn.transformer.attention_mask import AttentionMaskFactory
  from fairseq2.nn.transformer.encoder_layer import TransformerEncoderLayer
  from fairseq2.nn.transformer.layer_norm import LayerNormFactory, create_standard_layer_norm
  from fairseq2.nn.transformer.norm_order import TransformerNormOrder
  from fairseq2.typing import DataType, Device, finaloverride
label_desc: Use image node_id 1 to create a new StandardTransformerEncoder object from inherited base classes: TransformerEncoder with example: obj = StandardTransformerEncoder(layers)