class_docstr: Transformer encoder module.
  
  For documentation on parameters that are take directly from opt,
  see parlai/agents/transformer/transformer.py
  
  :param opt: ParlAI-parsed options.
  :param vocabulary_size: Count of tokens/words in the dictionary.
  :param embedding: an embedding matrix for the bottom layer of the transformer.
      If none, one is created for this encoder.
  :param int padding_idx: Reserved padding index in the embeddings matrix.
  :param str reduction_type: Type of reduction at the end of the encoder.
  :param int n_positions: Size of the position embeddings matrix.
  :param int n_segments: Number of segments/lang/sentence embeddings.
  :param bool embeddings_scale: Scale embeddings relative to their dimensionality.
      Found useful in fairseq.
class_docstr_tok: ["Transformer","encoder","module",".","For","documentation","on","parameters","that","are","take","directly","from","opt",",","see","parlai\/agents\/transformer\/transformer.py",":","param","opt",":","ParlAI-parsed","options",".",":","param","vocabulary_size",":","Count","of","tokens\/words","in","the","dictionary",".",":","param","embedding",":","an","embedding","matrix","for","the","bottom","layer","of","the","transformer",".","If","none",",","one","is","created","for","this","encoder",".",":","param","int","padding_idx",":","Reserved","padding","index","in","the","embeddings","matrix",".",":","param","str","reduction_type",":","Type","of","reduction","at","the","end","of","the","encoder",".",":","param","int","n_positions",":","Size","of","the","position","embeddings","matrix",".",":","param","int","n_segments",":","Number","of","segments\/lang\/sentence","embeddings",".",":","param","bool","embeddings_scale",":","Scale","embeddings","relative","to","their","dimensionality",".","Found","useful","in","fairseq","."]
code: def build_layers(self) -> nn.ModuleList:
      layers = nn.ModuleList()
      for _ in range(self.n_layers):
          layer = self.swappables.layer(  # type: ignore
              self.opt,
              attention_dropout=self.opt.get("attention_dropout", 0.0),
              relu_dropout=self.opt.get("relu_dropout", 0.0),
              dropout=self.dropout_frac,
              variant=self.variant,
              activation=self.activation,
          )
          if self.opt.get("checkpoint_activations"):
              layer = checkpoint_wrapper(layer)
          layers.append(fsdp_wrap(layer))
      return layers
  
imports: from __future__ import annotations
  from typing import Tuple, Optional, Union
  import numpy
  import torch
  import torch.nn
  from parlai.agents.transformer.modules import create_position_codes, get_n_positions_from_options, LAYER_NORM_EPS, MultiHeadAttention, TransformerFFN
  from parlai.agents.transformer.modules.modular import swappable
  from parlai.core.opt import Opt
  from parlai.core.params import default
  from parlai.utils.misc import warn_once
  from parlai.utils.torch import PipelineHelper
  from parlai.utils.fsdp import fsdp_wrap
  from parlai.nn.checkpoint import checkpoint_wrapper
label_desc: Use image node_id 2 for calling the TransformerEncoder obj's underlying member method code with example usage: obj.build_layers() and returns: layers