class_docstr: Encoder of DAB-DETR.
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_feat_points, dim).
      key_padding_mask (Tensor): ByteTensor, the key padding mask
          of the queries, has shape (bs, num_feat_points).
  
  Returns:
      Tensor: With shape (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_feat_points",",","dim",")",".","key_padding_mask","(","Tensor",")",":","ByteTensor",",","the","key","padding","mask","of","the","queries",",","has","shape","(","bs",",","num_feat_points",")",".","Returns",":","Tensor",":","With","shape","(","num_queries",",","bs",",","dim",")","."]
code: def forward(
      self,
      query: Tensor,
      query_pos: Tensor,
      key_padding_mask: Tensor,
      **kwargs,
  ):
      """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_feat_points, dim).
          key_padding_mask (Tensor): ByteTensor, the key padding mask
              of the queries, has shape (bs, num_feat_points).
  
      Returns:
          Tensor: With shape (num_queries, bs, dim).
      """
  
      for layer in self.layers:
          pos_scales = self.query_scale(query)
          query = layer(
              query,
              query_pos=query_pos * pos_scales,
              key_padding_mask=key_padding_mask,
              **kwargs,
          )
  
      return query
  
imports: from typing import List
  import torch
  import torch.nn
  from mmcv.cnn import build_norm_layer
  from mmcv.cnn.bricks.transformer import FFN
  from mmengine.model import ModuleList
  from torch import Tensor
  from .detr_layers import DetrTransformerDecoder, DetrTransformerDecoderLayer, DetrTransformerEncoder, DetrTransformerEncoderLayer
  from .utils import MLP, ConditionalAttention, coordinate_to_encoding, inverse_sigmoid
label_desc: Use image node_id 2 for calling the DABDetrTransformerEncoder obj's underlying member method code with example usage: obj.forward(query, query_pos, key_padding_mask) and returns: query