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: Forward function of encoder.
  
  Args:
      query (Tensor): Input queries of encoder, has shape
          (bs, num_queries, dim).
      query_pos (Tensor): The positional embeddings of the queries, has
          shape (bs, num_queries, dim).
      key_padding_mask (Tensor): The `key_padding_mask` of `self_attn`
          input. ByteTensor, has shape (bs, num_queries).
  
  Returns:
      Tensor: Has shape (bs, num_queries, dim) if `batch_first` is
      `True`, otherwise (num_queries, bs, dim).
docstr_tok: ["Forward","function","of","encoder",".","Args",":","query","(","Tensor",")",":","Input","queries","of","encoder",",","has","shape","(","bs",",","num_queries",",","dim",")",".","query_pos","(","Tensor",")",":","The","positional","embeddings","of","the","queries",",","has","shape","(","bs",",","num_queries",",","dim",")",".","key_padding_mask","(","Tensor",")",":","The","`","key_padding_mask","`","of","`","self_attn","`","input",".","ByteTensor",",","has","shape","(","bs",",","num_queries",")",".","Returns",":","Tensor",":","Has","shape","(","bs",",","num_queries",",","dim",")","if","`","batch_first","`","is","`","True","`",",","otherwise","(","num_queries",",","bs",",","dim",")","."]
code: def forward(
      self,
      query: Tensor,
      query_pos: Tensor,
      key_padding_mask: Tensor,
      **kwargs,
  ) -> Tensor:
      """Forward function of encoder.
  
      Args:
          query (Tensor): Input queries of encoder, has shape
              (bs, num_queries, dim).
          query_pos (Tensor): The positional embeddings of the queries, has
              shape (bs, num_queries, dim).
          key_padding_mask (Tensor): The `key_padding_mask` of `self_attn`
              input. ByteTensor, has shape (bs, num_queries).
  
      Returns:
          Tensor: Has shape (bs, num_queries, dim) if `batch_first` is
          `True`, otherwise (num_queries, bs, dim).
      """
      for layer in self.layers:
          query = layer(query, query_pos, key_padding_mask, **kwargs)
      return query
  
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 3 for calling the DetrTransformerEncoder obj's underlying member method code with example usage: obj.forward(query, query_pos, key_padding_mask) and returns: query