class_docstr: RPNHead in the `Sparse R-CNN <https://arxiv.org/abs/2011.12450>`_ .
  
  Unlike traditional RPNHead, this module does not need FPN input, but just
  decode `init_proposal_bboxes` and expand the first dimension of
  `init_proposal_bboxes` and `init_proposal_features` to the batch_size.
  
  Args:
      num_proposals (int): Number of init_proposals. Defaults to 100.
      proposal_feature_channel (int): Channel number of
          init_proposal_feature. Defaults to 256.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict]): Initialization config dict. Defaults to None.
class_docstr_tok: ["RPNHead","in","the","`","Sparse","R-CNN","<","https",":","\/\/arxiv.org\/abs\/2011.12450",">","`","_",".","Unlike","traditional","RPNHead",",","this","module","does","not","need","FPN","input",",","but","just","decode","`","init_proposal_bboxes","`","and","expand","the","first","dimension","of","`","init_proposal_bboxes","`","and","`","init_proposal_features","`","to","the","batch_size",".","Args",":","num_proposals","(","int",")",":","Number","of","init_proposals",".","Defaults","to","100.","proposal_feature_channel","(","int",")",":","Channel","number","of","init_proposal_feature",".","Defaults","to","256.","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",")",":","Initialization","config","dict",".","Defaults","to","None","."]
docstr: Decode init_proposal_bboxes according to the size of images and
  expand dimension of init_proposal_features to batch_size.
  
  Args:
      x (list[Tensor]): List of FPN features.
      batch_data_samples (List[:obj:`DetDataSample`]): The Data
          Samples. It usually includes information such as
          `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
  
  Returns:
      List[:obj:`InstanceData`:] Detection results of each image.
      Each item usually contains following keys.
  
      - proposals: Decoded proposal bboxes,
        has shape (num_proposals, 4).
      - features: init_proposal_features, expanded proposal
        features, has shape
        (num_proposals, proposal_feature_channel).
      - imgs_whwh: Tensor with shape
        (num_proposals, 4), the dimension means
        [img_width, img_height, img_width, img_height].
docstr_tok: ["Decode","init_proposal_bboxes","according","to","the","size","of","images","and","expand","dimension","of","init_proposal_features","to","batch_size",".","Args",":","x","(","list","[","Tensor","]",")",":","List","of","FPN","features",".","batch_data_samples","(","List","[",":","obj",":","`","DetDataSample","`","]",")",":","The","Data","Samples",".","It","usually","includes","information","such","as","`","gt_instance","`",",","`","gt_panoptic_seg","`","and","`","gt_sem_seg","`",".","Returns",":","List","[",":","obj",":","`","InstanceData","`",":","]","Detection","results","of","each","image",".","Each","item","usually","contains","following","keys",".","-","proposals",":","Decoded","proposal","bboxes",",","has","shape","(","num_proposals",",","4",")",".","-","features",":","init_proposal_features",",","expanded","proposal","features",",","has","shape","(","num_proposals",",","proposal_feature_channel",")",".","-","imgs_whwh",":","Tensor","with","shape","(","num_proposals",",","4",")",",","the","dimension","means","[","img_width",",","img_height",",","img_width",",","img_height","]","."]
code: def _decode_init_proposals(
      self, x: List[Tensor], batch_data_samples: SampleList
  ) -> InstanceList:
      """Decode init_proposal_bboxes according to the size of images and
      expand dimension of init_proposal_features to batch_size.
  
      Args:
          x (list[Tensor]): List of FPN features.
          batch_data_samples (List[:obj:`DetDataSample`]): The Data
              Samples. It usually includes information such as
              `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
  
      Returns:
          List[:obj:`InstanceData`:] Detection results of each image.
          Each item usually contains following keys.
  
          - proposals: Decoded proposal bboxes,
            has shape (num_proposals, 4).
          - features: init_proposal_features, expanded proposal
            features, has shape
            (num_proposals, proposal_feature_channel).
          - imgs_whwh: Tensor with shape
            (num_proposals, 4), the dimension means
            [img_width, img_height, img_width, img_height].
      """
      batch_img_metas = []
      for data_sample in batch_data_samples:
          batch_img_metas.append(data_sample.metainfo)
  
      proposals = self.init_proposal_bboxes.weight.clone()
      proposals = bbox_cxcywh_to_xyxy(proposals)
      imgs_whwh = []
      for meta in batch_img_metas:
          h, w = meta["img_shape"][:2]
          imgs_whwh.append(x[0].new_tensor([[w, h, w, h]]))
      imgs_whwh = torch.cat(imgs_whwh, dim=0)
      imgs_whwh = imgs_whwh[:, None, :]
      proposals = proposals * imgs_whwh
  
      rpn_results_list = []
      for idx in range(len(batch_img_metas)):
          rpn_results = InstanceData()
          rpn_results.bboxes = proposals[idx]
          rpn_results.imgs_whwh = imgs_whwh[idx].repeat(
              self.num_proposals, 1
          )
          rpn_results.features = (
              self.init_proposal_features.weight.clone()
          )
          rpn_results_list.append(rpn_results)
      return rpn_results_list
  
file_path: mmdetection/mmdet/models/dense_heads/embedding_rpn_head.py
imports: from typing import List
  import torch
  import torch.nn
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures.bbox import bbox_cxcywh_to_xyxy
  from mmdet.structures.det_data_sample import SampleList
  from mmdet.utils import InstanceList, OptConfigType
label_desc: Use image node_id 4 for calling the EmbeddingRPNHead obj's underlying member method code with example usage: obj._decode_init_proposals(x, batch_data_samples) and returns: rpn_results_list