class_docstr: Implements encoder layer in DETR transformer.
  
  Args:
      self_attn_cfg (:obj:`ConfigDict` or dict, optional): Config for self
          attention.
      ffn_cfg (:obj:`ConfigDict` or dict, optional): Config for FFN.
      norm_cfg (:obj:`ConfigDict` or dict, optional): Config for
          normalization layers. All the layers will share the same
          config. Defaults to `LN`.
      init_cfg (:obj:`ConfigDict` or dict, optional): Config to control
          the initialization. Defaults to None.
class_docstr_tok: ["Implements","encoder","layer","in","DETR","transformer",".","Args",":","self_attn_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","for","self","attention",".","ffn_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","for","FFN",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","for","normalization","layers",".","All","the","layers","will","share","the","same","config",".","Defaults","to","`","LN","`",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","to","control","the","initialization",".","Defaults","to","None","."]
code: def __init__(
      self,
      self_attn_cfg: OptConfigType = dict(
          embed_dims=256, num_heads=8, dropout=0.0
      ),
      ffn_cfg: OptConfigType = dict(
          embed_dims=256,
          feedforward_channels=1024,
          num_fcs=2,
          ffn_drop=0.0,
          act_cfg=dict(type="ReLU", inplace=True),
      ),
      norm_cfg: OptConfigType = dict(type="LN"),
      init_cfg: OptConfigType = None,
  ) -> None:
      super().__init__(init_cfg=init_cfg)
  
      self.self_attn_cfg = self_attn_cfg
      if "batch_first" not in self.self_attn_cfg:
          self.self_attn_cfg["batch_first"] = True
      else:
          assert (
              self.self_attn_cfg["batch_first"] is True
          ), "First \
              dimension of all DETRs in mmdet is `batch`, \
              please set `batch_first` flag."
  
      self.ffn_cfg = ffn_cfg
      self.norm_cfg = norm_cfg
      self._init_layers()
  
imports: from typing import Union
  import torch
  from mmcv.cnn import build_norm_layer
  from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention
  from mmengine import ConfigDict
  from mmengine.model import BaseModule, ModuleList
  from torch import Tensor
  from mmdet.utils import ConfigType, OptConfigType
label_desc: Use image node_id 1 to create a new DetrTransformerEncoderLayer object from inherited base classes: BaseModule with example: obj = DetrTransformerEncoderLayer(_attn_cfg, ffn_cfg, norm_cfg, init_cfg)