class_docstr: Head of the DINO: DETR with Improved DeNoising Anchor Boxes
  for End-to-End Object Detection
  
  Code is modified from the `official github repo
  <https://github.com/IDEA-Research/DINO>`_.
  
  More details can be found in the `paper
  <https://arxiv.org/abs/2203.03605>`_ .
class_docstr_tok: ["Head","of","the","DINO",":","DETR","with","Improved","DeNoising","Anchor","Boxes","for","End-to-End","Object","Detection","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/IDEA-Research\/DINO",">","`","_",".","More","details","can","be","found","in","the","`","paper","<","https",":","\/\/arxiv.org\/abs\/2203.03605",">","`","_","."]
docstr: Get targets in denoising part for a batch of images.
  
  Args:
      batch_gt_instances (list[:obj:`InstanceData`]): Batch of
          gt_instance. It usually includes ``bboxes`` and ``labels``
          attributes.
      batch_img_metas (list[dict]): Meta information of each image, e.g.,
          image size, scaling factor, etc.
      dn_meta (Dict[str, int]): The dictionary saves information about
        group collation, including 'num_denoising_queries' and
        'num_denoising_groups'. It will be used for split outputs of
        denoising and matching parts and loss calculation.
  
  Returns:
      tuple: a tuple containing the following targets.
  
      - labels_list (list[Tensor]): Labels for all images.
      - label_weights_list (list[Tensor]): Label weights for all images.
      - bbox_targets_list (list[Tensor]): BBox targets for all images.
      - bbox_weights_list (list[Tensor]): BBox weights for all images.
      - num_total_pos (int): Number of positive samples in all images.
      - num_total_neg (int): Number of negative samples in all images.
docstr_tok: ["Get","targets","in","denoising","part","for","a","batch","of","images",".","Args",":","batch_gt_instances","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Batch","of","gt_instance",".","It","usually","includes","``","bboxes","``","and","``","labels","``","attributes",".","batch_img_metas","(","list","[","dict","]",")",":","Meta","information","of","each","image",",","e.g.",",","image","size",",","scaling","factor",",","etc",".","dn_meta","(","Dict","[","str",",","int","]",")",":","The","dictionary","saves","information","about","group","collation",",","including","'num_denoising_queries","'","and","'num_denoising_groups","'",".","It","will","be","used","for","split","outputs","of","denoising","and","matching","parts","and","loss","calculation",".","Returns",":","tuple",":","a","tuple","containing","the","following","targets",".","-","labels_list","(","list","[","Tensor","]",")",":","Labels","for","all","images",".","-","label_weights_list","(","list","[","Tensor","]",")",":","Label","weights","for","all","images",".","-","bbox_targets_list","(","list","[","Tensor","]",")",":","BBox","targets","for","all","images",".","-","bbox_weights_list","(","list","[","Tensor","]",")",":","BBox","weights","for","all","images",".","-","num_total_pos","(","int",")",":","Number","of","positive","samples","in","all","images",".","-","num_total_neg","(","int",")",":","Number","of","negative","samples","in","all","images","."]
code: def get_dn_targets(
      self,
      batch_gt_instances: InstanceList,
      batch_img_metas: dict,
      dn_meta: Dict[str, int],
  ) -> tuple:
      """Get targets in denoising part for a batch of images.
  
      Args:
          batch_gt_instances (list[:obj:`InstanceData`]): Batch of
              gt_instance. It usually includes ``bboxes`` and ``labels``
              attributes.
          batch_img_metas (list[dict]): Meta information of each image, e.g.,
              image size, scaling factor, etc.
          dn_meta (Dict[str, int]): The dictionary saves information about
            group collation, including 'num_denoising_queries' and
            'num_denoising_groups'. It will be used for split outputs of
            denoising and matching parts and loss calculation.
  
      Returns:
          tuple: a tuple containing the following targets.
  
          - labels_list (list[Tensor]): Labels for all images.
          - label_weights_list (list[Tensor]): Label weights for all images.
          - bbox_targets_list (list[Tensor]): BBox targets for all images.
          - bbox_weights_list (list[Tensor]): BBox weights for all images.
          - num_total_pos (int): Number of positive samples in all images.
          - num_total_neg (int): Number of negative samples in all images.
      """
      (
          labels_list,
          label_weights_list,
          bbox_targets_list,
          bbox_weights_list,
          pos_inds_list,
          neg_inds_list,
      ) = multi_apply(
          self._get_dn_targets_single,
          batch_gt_instances,
          batch_img_metas,
          dn_meta=dn_meta,
      )
      num_total_pos = sum((inds.numel() for inds in pos_inds_list))
      num_total_neg = sum((inds.numel() for inds in neg_inds_list))
      return (
          labels_list,
          label_weights_list,
          bbox_targets_list,
          bbox_weights_list,
          num_total_pos,
          num_total_neg,
      )
  
imports: from typing import Dict, List, Tuple
  import torch
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy, bbox_overlaps, bbox_xyxy_to_cxcywh
  from mmdet.utils import InstanceList, OptInstanceList, reduce_mean
  from ..losses import QualityFocalLoss
  from ..utils import multi_apply
  from .deformable_detr_head import DeformableDETRHead
label_desc: Use image node_id 5 for calling the DINOHead obj's underlying member method code with example usage: obj.get_dn_targets(batch_gt_instances, batch_img_metas, dn_meta) and returns: labels_list,  label_weights_list,  bbox_targets_list,  bbox_weights_list,  num_total_pos,  num_total_neg