class_docstr: Implementation of `Dense Distinct Query for
  End-to-End Object Detection <https://arxiv.org/abs/2303.12776>`_
  
  Code is modified from the `official github repo
  <https://github.com/jshilong/DDQ>`_.
  
  Args:
      dense_topk_ratio (float): Ratio of num_dense queries to num_queries.
          Defaults to 1.5.
      dqs_cfg (:obj:`ConfigDict` or dict, optional): Config of
          Distinct Queries Selection. Defaults to nms with
          `iou_threshold` = 0.8.
class_docstr_tok: ["Implementation","of","`","Dense","Distinct","Query","for","End-to-End","Object","Detection","<","https",":","\/\/arxiv.org\/abs\/2303.12776",">","`","_","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/jshilong\/DDQ",">","`","_",".","Args",":","dense_topk_ratio","(","float",")",":","Ratio","of","num_dense","queries","to","num_queries",".","Defaults","to","1.5.","dqs_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of","Distinct","Queries","Selection",".","Defaults","to","nms","with","`","iou_threshold","`","=","0.8","."]
code: def __init__(
      self,
      *args,
      dense_topk_ratio: float = 1.5,
      dqs_cfg: OptConfigType = dict(type="nms", iou_threshold=0.8),
      **kwargs,
  ):
      self.dense_topk_ratio = dense_topk_ratio
      self.decoder_cfg = kwargs["decoder"]
      self.dqs_cfg = dqs_cfg
      super().__init__(*args, **kwargs)
  
      # a share dict in all moduls
      # pass some intermediate results and config parameters
      cache_dict = dict()
      for m in self.modules():
          m.cache_dict = cache_dict
      # first element is the start index of matching queries
      # second element is the number of matching queries
      self.cache_dict["dis_query_info"] = [0, 0]
  
      # mask for distinct queries in each decoder layer
      self.cache_dict["distinct_query_mask"] = []
      # pass to decoder do the dqs
      self.cache_dict["cls_branches"] = self.bbox_head.cls_branches
      # Used to construct the attention mask after dqs
      self.cache_dict["num_heads"] = self.encoder.layers[
          0
      ].self_attn.num_heads
      # pass to decoder to do the dqs
      self.cache_dict["dqs_cfg"] = self.dqs_cfg
  
file_path: mmdetection/mmdet/models/detectors/ddq_detr.py
imports: from typing import Dict, Tuple
  import torch
  from mmcv.ops import MultiScaleDeformableAttention, batched_nms
  from torch import Tensor, nn
  from torch.nn.init import normal_
  from mmdet.registry import MODELS
  from mmdet.structures import OptSampleList
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy
  from mmdet.utils import OptConfigType
  from ..layers import DDQTransformerDecoder
  from ..utils import align_tensor
  from .deformable_detr import DeformableDETR
  from .dino import DINO
label_desc: Use image node_id 1 to create a new DDQDETR object from inherited base classes: DINO with example: obj = DDQDETR()