class_docstr: Head of DeformDETR: Deformable DETR: Deformable Transformers for
  End-to-End Object Detection.
  
  Code is modified from the `official github repo
  <https://github.com/fundamentalvision/Deformable-DETR>`_.
  
  More details can be found in the `paper
  <https://arxiv.org/abs/2010.04159>`_ .
  
  Args:
      share_pred_layer (bool): Whether to share parameters for all the
          prediction layers. Defaults to `False`.
      num_pred_layer (int): The number of the prediction layers.
          Defaults to 6.
      as_two_stage (bool, optional): Whether to generate the proposal
          from the outputs of encoder. Defaults to `False`.
docstr: Perform forward propagation and loss calculation of the detection
  head on the queries of the upstream network.
  
  Args:
      hidden_states (Tensor): Hidden states output from each decoder
          layer, has shape (num_decoder_layers, num_queries, bs, dim).
      references (list[Tensor]): List of the reference from the decoder.
          The first reference is the `init_reference` (initial) and the
          other num_decoder_layers(6) references are `inter_references`
          (intermediate). The `init_reference` has shape (bs,
          num_queries, 4) when `as_two_stage` of the detector is `True`,
          otherwise (bs, num_queries, 2). Each `inter_reference` has
          shape (bs, num_queries, 4) when `with_box_refine` of the
          detector is `True`, otherwise (bs, num_queries, 2). The
          coordinates are arranged as (cx, cy) when the last dimension is
          2, and (cx, cy, w, h) when it is 4.
      batch_data_samples (list[:obj:`DetDataSample`]): The Data
          Samples. It usually includes information such as
          `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
      rescale (bool, optional): If `True`, return boxes in original
          image space. Defaults to `True`.
  
  Returns:
      list[obj:`InstanceData`]: Detection results of each image
      after the post process.
docstr_tok: ["Perform","forward","propagation","and","loss","calculation","of","the","detection","head","on","the","queries","of","the","upstream","network",".","Args",":","hidden_states","(","Tensor",")",":","Hidden","states","output","from","each","decoder","layer",",","has","shape","(","num_decoder_layers",",","num_queries",",","bs",",","dim",")",".","references","(","list","[","Tensor","]",")",":","List","of","the","reference","from","the","decoder",".","The","first","reference","is","the","`","init_reference","`","(","initial",")","and","the","other","num_decoder_layers","(","6",")","references","are","`","inter_references","`","(","intermediate",")",".","The","`","init_reference","`","has","shape","(","bs",",","num_queries",",","4",")","when","`","as_two_stage","`","of","the","detector","is","`","True","`",",","otherwise","(","bs",",","num_queries",",","2",")",".","Each","`","inter_reference","`","has","shape","(","bs",",","num_queries",",","4",")","when","`","with_box_refine","`","of","the","detector","is","`","True","`",",","otherwise","(","bs",",","num_queries",",","2",")",".","The","coordinates","are","arranged","as","(","cx",",","cy",")","when","the","last","dimension","is","2",",","and","(","cx",",","cy",",","w",",","h",")","when","it","is","4.","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","The","Data","Samples",".","It","usually","includes","information","such","as","`","gt_instance","`",",","`","gt_panoptic_seg","`","and","`","gt_sem_seg","`",".","rescale","(","bool",",","optional",")",":","If","`","True","`",",","return","boxes","in","original","image","space",".","Defaults","to","`","True","`",".","Returns",":","list","[","obj",":","`","InstanceData","`","]",":","Detection","results","of","each","image","after","the","post","process","."]
code: def predict(
      self,
      hidden_states: Tensor,
      references: List[Tensor],
      batch_data_samples: SampleList,
      rescale: bool = True,
  ) -> InstanceList:
      """Perform forward propagation and loss calculation of the detection
      head on the queries of the upstream network.
  
      Args:
          hidden_states (Tensor): Hidden states output from each decoder
              layer, has shape (num_decoder_layers, num_queries, bs, dim).
          references (list[Tensor]): List of the reference from the decoder.
              The first reference is the `init_reference` (initial) and the
              other num_decoder_layers(6) references are `inter_references`
              (intermediate). The `init_reference` has shape (bs,
              num_queries, 4) when `as_two_stage` of the detector is `True`,
              otherwise (bs, num_queries, 2). Each `inter_reference` has
              shape (bs, num_queries, 4) when `with_box_refine` of the
              detector is `True`, otherwise (bs, num_queries, 2). The
              coordinates are arranged as (cx, cy) when the last dimension is
              2, and (cx, cy, w, h) when it is 4.
          batch_data_samples (list[:obj:`DetDataSample`]): The Data
              Samples. It usually includes information such as
              `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
          rescale (bool, optional): If `True`, return boxes in original
              image space. Defaults to `True`.
  
      Returns:
          list[obj:`InstanceData`]: Detection results of each image
          after the post process.
      """
      batch_img_metas = [
          data_samples.metainfo for data_samples in batch_data_samples
      ]
  
      outs = self(hidden_states, references)
  
      predictions = self.predict_by_feat(
          *outs, batch_img_metas=batch_img_metas, rescale=rescale
      )
      return predictions
  
imports: import copy
  from typing import Dict, List, Tuple
  import torch
  import torch.nn
  from mmcv.cnn import Linear
  from mmengine.model import bias_init_with_prob, constant_init
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import InstanceList, OptInstanceList
  from ..layers import inverse_sigmoid
  from .detr_head import DETRHead
label_desc: Use image node_id 7 for calling the DeformableDETRHead obj's underlying member method code with example usage: obj.predict(hidden_states, references, batch_data_samples, rescale) and returns: predictions