class_docstr: Simplest RoI head, with only two fc layers for classification and
  regression respectively.
class_docstr_tok: ["Simplest","RoI","head",",","with","only","two","fc","layers","for","classification","and","regression","respectively","."]
docstr: Regress the bbox for the predicted class. Used in Cascade R-CNN.
  
  Args:
      priors (Tensor): Priors from `rpn_head` or last stage
          `bbox_head`, has shape (num_proposals, 4).
      label (Tensor): Only used when `self.reg_class_agnostic`
          is False, has shape (num_proposals, ).
      bbox_pred (Tensor): Regression prediction of
          current stage `bbox_head`. When `self.reg_class_agnostic`
          is False, it has shape (n, num_classes * 4), otherwise
          it has shape (n, 4).
      img_meta (dict): Image meta info.
  
  Returns:
      Tensor: Regressed bboxes, the same shape as input rois.
docstr_tok: ["Regress","the","bbox","for","the","predicted","class",".","Used","in","Cascade","R-CNN",".","Args",":","priors","(","Tensor",")",":","Priors","from","`","rpn_head","`","or","last","stage","`","bbox_head","`",",","has","shape","(","num_proposals",",","4",")",".","label","(","Tensor",")",":","Only","used","when","`","self.reg_class_agnostic","`","is","False",",","has","shape","(","num_proposals",",",")",".","bbox_pred","(","Tensor",")",":","Regression","prediction","of","current","stage","`","bbox_head","`",".","When","`","self.reg_class_agnostic","`","is","False",",","it","has","shape","(","n",",","num_classes","*","4",")",",","otherwise","it","has","shape","(","n",",","4",")",".","img_meta","(","dict",")",":","Image","meta","info",".","Returns",":","Tensor",":","Regressed","bboxes",",","the","same","shape","as","input","rois","."]
code: def regress_by_class(
      self,
      priors: Tensor,
      label: Tensor,
      bbox_pred: Tensor,
      img_meta: dict,
  ) -> Tensor:
      """Regress the bbox for the predicted class. Used in Cascade R-CNN.
  
      Args:
          priors (Tensor): Priors from `rpn_head` or last stage
              `bbox_head`, has shape (num_proposals, 4).
          label (Tensor): Only used when `self.reg_class_agnostic`
              is False, has shape (num_proposals, ).
          bbox_pred (Tensor): Regression prediction of
              current stage `bbox_head`. When `self.reg_class_agnostic`
              is False, it has shape (n, num_classes * 4), otherwise
              it has shape (n, 4).
          img_meta (dict): Image meta info.
  
      Returns:
          Tensor: Regressed bboxes, the same shape as input rois.
      """
      reg_dim = self.bbox_coder.encode_size
      if not self.reg_class_agnostic:
          label = label * reg_dim
          inds = torch.stack([label + i for i in range(reg_dim)], 1)
          bbox_pred = torch.gather(bbox_pred, 1, inds)
      assert bbox_pred.size()[1] == reg_dim
  
      max_shape = img_meta["img_shape"]
      regressed_bboxes = self.bbox_coder.decode(
          priors, bbox_pred, max_shape=max_shape
      )
      return regressed_bboxes
  
imports: from typing import List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.models.layers import multiclass_nms
  from mmdet.models.losses import accuracy
  from mmdet.models.task_modules.samplers import SamplingResult
  from mmdet.models.utils import empty_instances, multi_apply
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.structures.bbox import get_box_tensor, scale_boxes
  from mmdet.utils import ConfigType, InstanceList, OptMultiConfig
label_desc: Use image node_id 13 for calling the BBoxHead obj's underlying member method code with example usage: obj.regress_by_class(priors, label, bbox_pred, img_meta) and returns: regressed_bboxes