class_docstr: Implementation of `DINO: DETR with Improved DeNoising Anchor Boxes
  for End-to-End Object Detection <https://arxiv.org/abs/2203.03605>`_
  
  Code is modified from the `official github repo
  <https://github.com/IDEA-Research/DINO>`_.
  
  Args:
      dn_cfg (:obj:`ConfigDict` or dict, optional): Config of denoising
          query generator. Defaults to `None`.
class_docstr_tok: ["Implementation","of","`","DINO",":","DETR","with","Improved","DeNoising","Anchor","Boxes","for","End-to-End","Object","Detection","<","https",":","\/\/arxiv.org\/abs\/2203.03605",">","`","_","Code","is","modified","from","the","`","official","github","repo","<","https",":","\/\/github.com\/IDEA-Research\/DINO",">","`","_",".","Args",":","dn_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of","denoising","query","generator",".","Defaults","to","`","None","`","."]
docstr: Forward process of Transformer.
  
  The forward procedure of the transformer is defined as:
  'pre_transformer' -> 'encoder' -> 'pre_decoder' -> 'decoder'
  More details can be found at `TransformerDetector.forward_transformer`
  in `mmdet/detector/base_detr.py`.
  The difference is that the ground truth in `batch_data_samples` is
  required for the `pre_decoder` to prepare the query of DINO.
  Additionally, DINO inherits the `pre_transformer` method and the
  `forward_encoder` method of DeformableDETR. More details about the
  two methods can be found in `mmdet/detector/deformable_detr.py`.
  
  Args:
      img_feats (tuple[Tensor]): Tuple of feature maps from neck. Each
          feature map has shape (bs, dim, H, W).
      batch_data_samples (list[:obj:`DetDataSample`]): The batch
          data samples. It usually includes information such
          as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.
          Defaults to None.
  
  Returns:
      dict: The dictionary of bbox_head function inputs, which always
      includes the `hidden_states` of the decoder output and may contain
      `references` including the initial and intermediate references.
docstr_tok: ["Forward","process","of","Transformer",".","The","forward","procedure","of","the","transformer","is","defined","as",":","'pre_transformer","'","-",">","'encoder","'","-",">","'pre_decoder","'","-",">","'decoder'","More","details","can","be","found","at","`","TransformerDetector.forward_transformer","`","in","`","mmdet\/detector\/base_detr.py","`",".","The","difference","is","that","the","ground","truth","in","`","batch_data_samples","`","is","required","for","the","`","pre_decoder","`","to","prepare","the","query","of","DINO",".","Additionally",",","DINO","inherits","the","`","pre_transformer","`","method","and","the","`","forward_encoder","`","method","of","DeformableDETR",".","More","details","about","the","two","methods","can","be","found","in","`","mmdet\/detector\/deformable_detr.py","`",".","Args",":","img_feats","(","tuple","[","Tensor","]",")",":","Tuple","of","feature","maps","from","neck",".","Each","feature","map","has","shape","(","bs",",","dim",",","H",",","W",")",".","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","The","batch","data","samples",".","It","usually","includes","information","such","as","`","gt_instance","`","or","`","gt_panoptic_seg","`","or","`","gt_sem_seg","`",".","Defaults","to","None",".","Returns",":","dict",":","The","dictionary","of","bbox_head","function","inputs",",","which","always","includes","the","`","hidden_states","`","of","the","decoder","output","and","may","contain","`","references","`","including","the","initial","and","intermediate","references","."]
code: def forward_transformer(
      self,
      img_feats: Tuple[Tensor],
      batch_data_samples: OptSampleList = None,
  ) -> Dict:
      """Forward process of Transformer.
  
      The forward procedure of the transformer is defined as:
      'pre_transformer' -> 'encoder' -> 'pre_decoder' -> 'decoder'
      More details can be found at `TransformerDetector.forward_transformer`
      in `mmdet/detector/base_detr.py`.
      The difference is that the ground truth in `batch_data_samples` is
      required for the `pre_decoder` to prepare the query of DINO.
      Additionally, DINO inherits the `pre_transformer` method and the
      `forward_encoder` method of DeformableDETR. More details about the
      two methods can be found in `mmdet/detector/deformable_detr.py`.
  
      Args:
          img_feats (tuple[Tensor]): Tuple of feature maps from neck. Each
              feature map has shape (bs, dim, H, W).
          batch_data_samples (list[:obj:`DetDataSample`]): The batch
              data samples. It usually includes information such
              as `gt_instance` or `gt_panoptic_seg` or `gt_sem_seg`.
              Defaults to None.
  
      Returns:
          dict: The dictionary of bbox_head function inputs, which always
          includes the `hidden_states` of the decoder output and may contain
          `references` including the initial and intermediate references.
      """
      encoder_inputs_dict, decoder_inputs_dict = self.pre_transformer(
          img_feats, batch_data_samples
      )
  
      encoder_outputs_dict = self.forward_encoder(**encoder_inputs_dict)
  
      tmp_dec_in, head_inputs_dict = self.pre_decoder(
          **encoder_outputs_dict, batch_data_samples=batch_data_samples
      )
      decoder_inputs_dict.update(tmp_dec_in)
  
      decoder_outputs_dict = self.forward_decoder(**decoder_inputs_dict)
      head_inputs_dict.update(decoder_outputs_dict)
      return head_inputs_dict
  
file_path: mmdetection/mmdet/models/detectors/dino.py
imports: from typing import Dict, Optional, Tuple
  import torch
  from torch import Tensor, nn
  from torch.nn.init import normal_
  from mmdet.registry import MODELS
  from mmdet.structures import OptSampleList
  from mmdet.utils import OptConfigType
  from ..layers import CdnQueryGenerator, DeformableDetrTransformerEncoder, DinoTransformerDecoder, SinePositionalEncoding
  from .deformable_detr import DeformableDETR, MultiScaleDeformableAttention
label_desc: Use image node_id 4 for calling the DINO obj's underlying member method code with example usage: obj.forward_transformer(img_feats, batch_data_samples) and returns: head_inputs_dict