class_docstr: Base class for TransformerEncoder and TransformerDecoder in vision
  transformer.
  
  As base-class of Encoder and Decoder in vision transformer.
  Support customization such as specifying different kind
  of `transformer_layer` in `transformer_coder`.
  
  Args:
      transformerlayer (list[obj:`mmcv.ConfigDict`] |
          obj:`mmcv.ConfigDict`): Config of transformerlayer
          in TransformerCoder. If it is obj:`mmcv.ConfigDict`,
           it would be repeated `num_layer` times to a
           list[`mmcv.ConfigDict`]. Default: None.
      num_layers (int): The number of `TransformerLayer`. Default: None.
      init_cfg (obj:`mmcv.ConfigDict`): The Config for initialization.
          Default: None.
class_docstr_tok: ["Base","class","for","TransformerEncoder","and","TransformerDecoder","in","vision","transformer",".","As","base-class","of","Encoder","and","Decoder","in","vision","transformer",".","Support","customization","such","as","specifying","different","kind","of","`","transformer_layer","`","in","`","transformer_coder","`",".","Args",":","transformerlayer","(","list","[","obj",":","`","mmcv.ConfigDict","`","]","|","obj",":","`","mmcv.ConfigDict","`",")",":","Config","of","transformerlayer","in","TransformerCoder",".","If","it","is","obj",":","`","mmcv.ConfigDict","`",",","it","would","be","repeated","`","num_layer","`","times","to","a","list","[","`","mmcv.ConfigDict","`","]",".","Default",":","None",".","num_layers","(","int",")",":","The","number","of","`","TransformerLayer","`",".","Default",":","None",".","init_cfg","(","obj",":","`","mmcv.ConfigDict","`",")",":","The","Config","for","initialization",".","Default",":","None","."]
code: def __init__(
      self, transformerlayers=None, num_layers=None, init_cfg=None
  ):
      super(TransformerLayerSequence, self).__init__(init_cfg)
      if isinstance(transformerlayers, dict):
          transformerlayers = [
              copy.deepcopy(transformerlayers)
              for _ in range(num_layers)
          ]
      else:
          assert (
              isinstance(transformerlayers, list)
              and len(transformerlayers) == num_layers
          )
      self.num_layers = num_layers
      self.layers = ModuleList()
      for i in range(num_layers):
          self.layers.append(
              build_transformer_layer(transformerlayers[i])
          )
      self.embed_dims = self.layers[0].embed_dims
      self.pre_norm = self.layers[0].pre_norm
  
imports: import copy
  import warnings
  import torch
  import torch.nn
  from annotator.uniformer.mmcv import ConfigDict, deprecated_api_warning
  from annotator.uniformer.mmcv.cnn import Linear, build_activation_layer, build_norm_layer
  from annotator.uniformer.mmcv.runner.base_module import BaseModule, ModuleList, Sequential
  from annotator.uniformer.mmcv.utils import build_from_cfg
  from .drop import build_dropout
  from .registry import ATTENTION, FEEDFORWARD_NETWORK, POSITIONAL_ENCODING, TRANSFORMER_LAYER, TRANSFORMER_LAYER_SEQUENCE
label_desc: Use image node_id 1 to create a new TransformerLayerSequence object from inherited base classes: BaseModule with example: obj = TransformerLayerSequence(transformerlayers, num_layers, init_cfg)