class_docstr: The roi head for Multi-instance prediction.
class_docstr_tok: ["The","roi","head","for","Multi-instance","prediction","."]
docstr: Box head forward function used in both training and testing.
  
  Args:
      x (tuple[Tensor]): List of multi-level img features.
      rois (Tensor): RoIs with the shape (n, 5) where the first
          column indicates batch id of each RoI.
  
  Returns:
       dict[str, Tensor]: Usually returns a dictionary with keys:
  
          - `cls_score` (Tensor): Classification scores.
          - `bbox_pred` (Tensor): Box energies / deltas.
          - `cls_score_ref` (Tensor): The cls_score after refine model.
          - `bbox_pred_ref` (Tensor): The bbox_pred after refine model.
          - `bbox_feats` (Tensor): Extract bbox RoI features.
docstr_tok: ["Box","head","forward","function","used","in","both","training","and","testing",".","Args",":","x","(","tuple","[","Tensor","]",")",":","List","of","multi-level","img","features",".","rois","(","Tensor",")",":","RoIs","with","the","shape","(","n",",","5",")","where","the","first","column","indicates","batch","id","of","each","RoI",".","Returns",":","dict","[","str",",","Tensor","]",":","Usually","returns","a","dictionary","with","keys",":","-","`","cls_score","`","(","Tensor",")",":","Classification","scores",".","-","`","bbox_pred","`","(","Tensor",")",":","Box","energies","\/","deltas",".","-","`","cls_score_ref","`","(","Tensor",")",":","The","cls_score","after","refine","model",".","-","`","bbox_pred_ref","`","(","Tensor",")",":","The","bbox_pred","after","refine","model",".","-","`","bbox_feats","`","(","Tensor",")",":","Extract","bbox","RoI","features","."]
code: def _bbox_forward(self, x: Tuple[Tensor], rois: Tensor) -> dict:
      """Box head forward function used in both training and testing.
  
      Args:
          x (tuple[Tensor]): List of multi-level img features.
          rois (Tensor): RoIs with the shape (n, 5) where the first
              column indicates batch id of each RoI.
  
      Returns:
           dict[str, Tensor]: Usually returns a dictionary with keys:
  
              - `cls_score` (Tensor): Classification scores.
              - `bbox_pred` (Tensor): Box energies / deltas.
              - `cls_score_ref` (Tensor): The cls_score after refine model.
              - `bbox_pred_ref` (Tensor): The bbox_pred after refine model.
              - `bbox_feats` (Tensor): Extract bbox RoI features.
      """
      # TODO: a more flexible way to decide which feature maps to use
      bbox_feats = self.bbox_roi_extractor(
          x[: self.bbox_roi_extractor.num_inputs], rois
      )
      bbox_results = self.bbox_head(bbox_feats)
  
      if self.bbox_head.with_refine:
          bbox_results = dict(
              cls_score=bbox_results[0],
              bbox_pred=bbox_results[1],
              cls_score_ref=bbox_results[2],
              bbox_pred_ref=bbox_results[3],
              bbox_feats=bbox_feats,
          )
      else:
          bbox_results = dict(
              cls_score=bbox_results[0],
              bbox_pred=bbox_results[1],
              bbox_feats=bbox_feats,
          )
  
      return bbox_results
  
file_path: mmdetection/mmdet/models/roi_heads/multi_instance_roi_head.py
imports: from typing import List, Tuple
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import DetDataSample
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import ConfigType, InstanceList
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances, unpack_gt_instances
  from .standard_roi_head import StandardRoIHead
label_desc: Use image node_id 3 for calling the MultiInstanceRoIHead obj's underlying member method code with example usage: obj._bbox_forward(x, rois) and returns: bbox_results