class_docstr: Head of Conditional DETR. Conditional DETR: Conditional DETR for Fast
  Training Convergence. More details can be found in the `paper.
  
  <https://arxiv.org/abs/2108.06152>`_ .
class_docstr_tok: ["Head","of","Conditional","DETR",".","Conditional","DETR",":","Conditional","DETR","for","Fast","Training","Convergence",".","More","details","can","be","found","in","the","`","paper",".","<","https",":","\/\/arxiv.org\/abs\/2108.06152",">","`","_","."]
docstr: Perform forward propagation of the head, then calculate loss and
  predictions from the features and data samples. Over-write because
  img_metas are needed as inputs for bbox_head.
  
  Args:
      hidden_states (Tensor): Features from the transformer decoder, has
          shape (num_decoder_layers, bs, num_queries, dim).
      references (Tensor): References from the transformer decoder, has
          shape (num_decoder_layers, bs, num_queries, 2).
      batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
          the meta information of each image and corresponding
          annotations.
  
  Returns:
      tuple: The return value is a tuple contains:
  
      - losses: (dict[str, Tensor]): A dictionary of loss components.
      - predictions (list[:obj:`InstanceData`]): Detection
        results of each image after the post process.
docstr_tok: ["Perform","forward","propagation","of","the","head",",","then","calculate","loss","and","predictions","from","the","features","and","data","samples",".","Over-write","because","img_metas","are","needed","as","inputs","for","bbox_head",".","Args",":","hidden_states","(","Tensor",")",":","Features","from","the","transformer","decoder",",","has","shape","(","num_decoder_layers",",","bs",",","num_queries",",","dim",")",".","references","(","Tensor",")",":","References","from","the","transformer","decoder",",","has","shape","(","num_decoder_layers",",","bs",",","num_queries",",","2",")",".","batch_data_samples","(","list","[",":","obj",":","`","DetDataSample","`","]",")",":","Each","item","contains","the","meta","information","of","each","image","and","corresponding","annotations",".","Returns",":","tuple",":","The","return","value","is","a","tuple","contains",":","-","losses",":","(","dict","[","str",",","Tensor","]",")",":","A","dictionary","of","loss","components",".","-","predictions","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","Detection","results","of","each","image","after","the","post","process","."]
code: def loss_and_predict(
      self,
      hidden_states: Tensor,
      references: Tensor,
      batch_data_samples: SampleList,
  ) -> Tuple[dict, InstanceList]:
      """Perform forward propagation of the head, then calculate loss and
      predictions from the features and data samples. Over-write because
      img_metas are needed as inputs for bbox_head.
  
      Args:
          hidden_states (Tensor): Features from the transformer decoder, has
              shape (num_decoder_layers, bs, num_queries, dim).
          references (Tensor): References from the transformer decoder, has
              shape (num_decoder_layers, bs, num_queries, 2).
          batch_data_samples (list[:obj:`DetDataSample`]): Each item contains
              the meta information of each image and corresponding
              annotations.
  
      Returns:
          tuple: The return value is a tuple contains:
  
          - losses: (dict[str, Tensor]): A dictionary of loss components.
          - predictions (list[:obj:`InstanceData`]): Detection
            results of each image after the post process.
      """
      batch_gt_instances = []
      batch_img_metas = []
      for data_sample in batch_data_samples:
          batch_img_metas.append(data_sample.metainfo)
          batch_gt_instances.append(data_sample.gt_instances)
  
      outs = self(hidden_states, references)
      loss_inputs = outs + (batch_gt_instances, batch_img_metas)
      losses = self.loss_by_feat(*loss_inputs)
  
      predictions = self.predict_by_feat(
          *outs, batch_img_metas=batch_img_metas
      )
      return losses, predictions
  
file_path: mmdetection/mmdet/models/dense_heads/conditional_detr_head.py
imports: from typing import Tuple
  import torch
  import torch.nn
  from mmengine.model import bias_init_with_prob
  from torch import Tensor
  from mmdet.models.layers.transformer import inverse_sigmoid
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import InstanceList
  from .detr_head import DETRHead
label_desc: Use image node_id 4 for calling the ConditionalDETRHead obj's underlying member method code with example usage: obj.loss_and_predict(hidden_states, references, batch_data_samples) and returns: losses,  predictions