class_docstr: Encoder of DETR.
  
  Args:
      num_layers (int): Number of encoder layers.
      layer_cfg (:obj:`ConfigDict` or dict): the config of each encoder
          layer. All the layers will share the same config.
      num_cp (int): Number of checkpointing blocks in encoder layer.
          Default to -1.
      init_cfg (:obj:`ConfigDict` or dict, optional): the config to control
          the initialization. Defaults to None.
class_docstr_tok: ["Encoder","of","DETR",".","Args",":","num_layers","(","int",")",":","Number","of","encoder","layers",".","layer_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","the","config","of","each","encoder","layer",".","All","the","layers","will","share","the","same","config",".","num_cp","(","int",")",":","Number","of","checkpointing","blocks","in","encoder","layer",".","Default","to","-1.","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","the","config","to","control","the","initialization",".","Defaults","to","None","."]
docstr: Initialize encoder layers.
docstr_tok: ["Initialize","encoder","layers","."]
code: def _init_layers(self) -> None:
      """Initialize encoder layers."""
      self.layers = ModuleList(
          [
              DetrTransformerEncoderLayer(**self.layer_cfg)
              for _ in range(self.num_layers)
          ]
      )
  
      if self.num_cp > 0:
          if checkpoint_wrapper is None:
              raise NotImplementedError(
                  "If you want to reduce GPU memory usage, \
                      please install fairscale by executing the \
                      following command: pip install fairscale."
              )
          for i in range(self.num_cp):
              self.layers[i] = checkpoint_wrapper(self.layers[i])
  
      self.embed_dims = self.layers[0].embed_dims
  
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 2 for calling the DetrTransformerEncoder obj's underlying member method code with example usage: obj._init_layers() without return types