class_docstr: The ROI heads that implement :paper:`Cascade R-CNN`.
class_docstr_tok: ["The","ROI","heads","that","implement",":","paper",":","`","Cascade","R-CNN","`","."]
docstr: Args:
      features (list[Tensor]): #lvl input features to ROIHeads
      proposals (list[Instances]): #image Instances, with the field "proposal_boxes"
      stage (int): the current stage
  
  Returns:
      Same output as `FastRCNNOutputLayers.forward()`.
docstr_tok: ["Args",":","features","(","list","[","Tensor","]",")",":","#","lvl","input","features","to","ROIHeads","proposals","(","list","[","Instances","]",")",":","#","image","Instances",",","with","the","field","``","proposal_boxes","''","stage","(","int",")",":","the","current","stage","Returns",":","Same","output","as","`","FastRCNNOutputLayers.forward","(",")","`","."]
code: def _run_stage(self, features, proposals, stage):
      """
      Args:
          features (list[Tensor]): #lvl input features to ROIHeads
          proposals (list[Instances]): #image Instances, with the field "proposal_boxes"
          stage (int): the current stage
  
      Returns:
          Same output as `FastRCNNOutputLayers.forward()`.
      """
      box_features = self.box_pooler(
          features, [x.proposal_boxes for x in proposals]
      )
      # The original implementation averages the losses among heads,
      # but scale up the parameter gradients of the heads.
      # This is equivalent to adding the losses among heads,
      # but scale down the gradients on features.
      if self.training:
          box_features = _ScaleGradient.apply(
              box_features, 1.0 / self.num_cascade_stages
          )
      box_features = self.box_head[stage](box_features)
      return self.box_predictor[stage](box_features)
  
imports: from typing import List
  import torch
  from torch import nn
  from torch.autograd.function import Function
  from detectron2.config import configurable
  from detectron2.layers import ShapeSpec
  from detectron2.structures import Boxes, Instances, pairwise_iou
  from detectron2.utils.events import get_event_storage
  from ..box_regression import Box2BoxTransform
  from ..matcher import Matcher
  from ..poolers import ROIPooler
  from .box_head import build_box_head
  from .fast_rcnn import FastRCNNOutputLayers, fast_rcnn_inference
  from .roi_heads import ROI_HEADS_REGISTRY, StandardROIHeads
label_desc: Use image node_id 7 for calling the CascadeROIHeads obj's underlying member method code with example usage: obj._run_stage(features, proposals, stage) and returns: self