class_docstr: The ROI heads that implement :paper:`Cascade R-CNN`.
class_docstr_tok: ["The","ROI","heads","that","implement",":","paper",":","`","Cascade","R-CNN","`","."]
code: def forward(self, images, features, proposals, targets=None):
      del images
      if self.training:
          proposals = self.label_and_sample_proposals(
              proposals, targets
          )
  
      if self.training:
          # Need targets to box head
          losses = self._forward_box(features, proposals, targets)
          losses.update(self._forward_mask(features, proposals))
          losses.update(self._forward_keypoint(features, proposals))
          return proposals, losses
      else:
          pred_instances = self._forward_box(features, proposals)
          pred_instances = self.forward_with_given_boxes(
              features, pred_instances
          )
          return pred_instances, {}
  
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 4 for calling the CascadeROIHeads obj's underlying member method code with example usage: obj.forward(images, features, proposals, targets) and returns: proposals,  losses, pred_instances,  dict