class_docstr: The ROI heads that implement :paper:`Cascade R-CNN`.
class_docstr_tok: ["The","ROI","heads","that","implement",":","paper",":","`","Cascade","R-CNN","`","."]
docstr: NOTE: this interface is experimental.
  
  Args:
      box_pooler (ROIPooler): pooler that extracts region features from given boxes
      box_heads (list[nn.Module]): box head for each cascade stage
      box_predictors (list[nn.Module]): box predictor for each cascade stage
      proposal_matchers (list[Matcher]): matcher with different IoU thresholds to
          match boxes with ground truth for each stage. The first matcher matches
          RPN proposals with ground truth, the other matchers use boxes predicted
          by the previous stage as proposals and match them with ground truth.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","box_pooler","(","ROIPooler",")",":","pooler","that","extracts","region","features","from","given","boxes","box_heads","(","list","[","nn.Module","]",")",":","box","head","for","each","cascade","stage","box_predictors","(","list","[","nn.Module","]",")",":","box","predictor","for","each","cascade","stage","proposal_matchers","(","list","[","Matcher","]",")",":","matcher","with","different","IoU","thresholds","to","match","boxes","with","ground","truth","for","each","stage",".","The","first","matcher","matches","RPN","proposals","with","ground","truth",",","the","other","matchers","use","boxes","predicted","by","the","previous","stage","as","proposals","and","match","them","with","ground","truth","."]
code: def __init__(
      self,
      *,
      box_in_features: List[str],
      box_pooler: ROIPooler,
      box_heads: List[nn.Module],
      box_predictors: List[nn.Module],
      proposal_matchers: List[Matcher],
      **kwargs,
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          box_pooler (ROIPooler): pooler that extracts region features from given boxes
          box_heads (list[nn.Module]): box head for each cascade stage
          box_predictors (list[nn.Module]): box predictor for each cascade stage
          proposal_matchers (list[Matcher]): matcher with different IoU thresholds to
              match boxes with ground truth for each stage. The first matcher matches
              RPN proposals with ground truth, the other matchers use boxes predicted
              by the previous stage as proposals and match them with ground truth.
      """
      assert "proposal_matcher" not in kwargs, (
          "CascadeROIHeads takes 'proposal_matchers=' for each stage instead "
          "of one 'proposal_matcher='."
      )
      # The first matcher matches RPN proposals with ground truth, done in the base class
      kwargs["proposal_matcher"] = proposal_matchers[0]
      num_stages = self.num_cascade_stages = len(box_heads)
      box_heads = nn.ModuleList(box_heads)
      box_predictors = nn.ModuleList(box_predictors)
      assert (
          len(box_predictors) == num_stages
      ), f"{len(box_predictors)} != {num_stages}!"
      assert (
          len(proposal_matchers) == num_stages
      ), f"{len(proposal_matchers)} != {num_stages}!"
      super().__init__(
          box_in_features=box_in_features,
          box_pooler=box_pooler,
          box_head=box_heads,
          box_predictor=box_predictors,
          **kwargs,
      )
      self.proposal_matchers = proposal_matchers
  
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 1 to create a new CascadeROIHeads object from inherited base classes: StandardROIHeads with example: obj = CascadeROIHeads()