class_docstr: A transformer-encoder structure based on the components from above.
class_docstr_tok: ["A","transformer-encoder","structure","based","on","the","components","from","above","."]
code: def __init__(self, idx, cfg_arch):
      super().__init__()
      self.dropout = torch.nn.Dropout(
          cfg_arch.hidden_dropout_prob, inplace=False
      )
      self.norm1 = _get_norm_fn(cfg_arch.norm)(
          cfg_arch.hidden_size, eps=cfg_arch.norm_eps
      )
      self.norm2 = _get_norm_fn(cfg_arch.norm)(
          cfg_arch.hidden_size, eps=cfg_arch.norm_eps
      )
      self.attn = AttentionComponent(
          idx,
          cfg_arch.hidden_size,
          cfg_arch.attention,
          cfg_arch.use_bias,
      )
      self.LAYOUT = self.attn.LAYOUT
  
      self.ffn = FFNComponent(
          cfg_arch.hidden_size,
          cfg_arch.intermed_size,
          _get_nonlin_fn(cfg_arch.nonlin),
          cfg_arch.use_bias,
      )
  
imports: import torch
  from typing import Optional
  from random import randrange
  from transformers import PretrainedConfig
  from .components import EmbeddingComponent, AttentionComponent, FFNComponent, PredictionHeadComponent, get_extended_attention_mask, _get_norm_fn, _get_nonlin_fn, _init_module
label_desc: Use image node_id 1 to create a new TransformerLayer object from inherited base classes: torch.nn with example: obj = TransformerLayer(idx, cfg_arch)