class_docstr: Hybrid task cascade roi head including one bbox head and one mask head.
  
  https://arxiv.org/abs/1901.07518
  
  Args:
      num_stages (int): Number of cascade stages.
      stage_loss_weights (list[float]): Loss weight for every stage.
      semantic_roi_extractor (:obj:`ConfigDict` or dict, optional):
          Config of semantic roi extractor. Defaults to None.
      Semantic_head (:obj:`ConfigDict` or dict, optional):
          Config of semantic head. Defaults to None.
      interleaved (bool): Whether to interleaves the box branch and mask
          branch. If True, the mask branch can take the refined bounding
          box predictions. Defaults to True.
      mask_info_flow (bool): Whether to turn on the mask information flow,
          which means that feeding the mask features of the preceding stage
          to the current stage. Defaults to True.
docstr: Perform forward propagation of the roi head and predict detection
  results on the features of the upstream network.
  
  Args:
      x (tuple[Tensor]): Features from upstream network. Each
          has shape (N, C, H, W).
      rpn_results_list (list[:obj:`InstanceData`]): list of region
          proposals.
      batch_data_samples (List[:obj:`DetDataSample`]): The Data
          Samples. It usually includes information such as
          `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
      rescale (bool): Whether to rescale the results to
          the original image. Defaults to False.
  
  Returns:
      list[obj:`InstanceData`]: Detection results of each image.
      Each item usually contains following keys.
  
          - scores (Tensor): Classification scores, has a shape
              (num_instance, )
          - labels (Tensor): Labels of bboxes, has a shape
              (num_instances, ).
          - bboxes (Tensor): Has a shape (num_instances, 4),
              the last dimension 4 arrange as (x1, y1, x2, y2).
          - masks (Tensor): Has a shape (num_instances, H, W).
docstr_tok: ["Perform","forward","propagation","of","the","roi","head","and","predict","detection","results","on","the","features","of","the","upstream","network",".","Args",":","x","(","tuple","[","Tensor","]",")",":","Features","from","upstream","network",".","Each","has","shape","(","N",",","C",",","H",",","W",")",".","rpn_results_list","(","list","[",":","obj",":","`","InstanceData","`","]",")",":","list","of","region","proposals",".","batch_data_samples","(","List","[",":","obj",":","`","DetDataSample","`","]",")",":","The","Data","Samples",".","It","usually","includes","information","such","as","`","gt_instance","`",",","`","gt_panoptic_seg","`","and","`","gt_sem_seg","`",".","rescale","(","bool",")",":","Whether","to","rescale","the","results","to","the","original","image",".","Defaults","to","False",".","Returns",":","list","[","obj",":","`","InstanceData","`","]",":","Detection","results","of","each","image",".","Each","item","usually","contains","following","keys",".","-","scores","(","Tensor",")",":","Classification","scores",",","has","a","shape","(","num_instance",",",")","-","labels","(","Tensor",")",":","Labels","of","bboxes",",","has","a","shape","(","num_instances",",",")",".","-","bboxes","(","Tensor",")",":","Has","a","shape","(","num_instances",",","4",")",",","the","last","dimension","4","arrange","as","(","x1",",","y1",",","x2",",","y2",")",".","-","masks","(","Tensor",")",":","Has","a","shape","(","num_instances",",","H",",","W",")","."]
code: def predict(
      self,
      x: Tuple[Tensor],
      rpn_results_list: InstanceList,
      batch_data_samples: SampleList,
      rescale: bool = False,
  ) -> InstanceList:
      """Perform forward propagation of the roi head and predict detection
      results on the features of the upstream network.
  
      Args:
          x (tuple[Tensor]): Features from upstream network. Each
              has shape (N, C, H, W).
          rpn_results_list (list[:obj:`InstanceData`]): list of region
              proposals.
          batch_data_samples (List[:obj:`DetDataSample`]): The Data
              Samples. It usually includes information such as
              `gt_instance`, `gt_panoptic_seg` and `gt_sem_seg`.
          rescale (bool): Whether to rescale the results to
              the original image. Defaults to False.
  
      Returns:
          list[obj:`InstanceData`]: Detection results of each image.
          Each item usually contains following keys.
  
              - scores (Tensor): Classification scores, has a shape
                  (num_instance, )
              - labels (Tensor): Labels of bboxes, has a shape
                  (num_instances, ).
              - bboxes (Tensor): Has a shape (num_instances, 4),
                  the last dimension 4 arrange as (x1, y1, x2, y2).
              - masks (Tensor): Has a shape (num_instances, H, W).
      """
      assert self.with_bbox, "Bbox head must be implemented."
      batch_img_metas = [
          data_samples.metainfo for data_samples in batch_data_samples
      ]
  
      if self.with_semantic:
          _, semantic_feat = self.semantic_head(x)
      else:
          semantic_feat = None
  
      # TODO: nms_op in mmcv need be enhanced, the bbox result may get
      #  difference when not rescale in bbox_head
  
      # If it has the mask branch, the bbox branch does not need
      # to be scaled to the original image scale, because the mask
      # branch will scale both bbox and mask at the same time.
      bbox_rescale = rescale if not self.with_mask else False
      results_list = self.predict_bbox(
          x=x,
          semantic_feat=semantic_feat,
          batch_img_metas=batch_img_metas,
          rpn_results_list=rpn_results_list,
          rcnn_test_cfg=self.test_cfg,
          rescale=bbox_rescale,
      )
  
      if self.with_mask:
          results_list = self.predict_mask(
              x=x,
              semantic_heat=semantic_feat,
              batch_img_metas=batch_img_metas,
              results_list=results_list,
              rescale=rescale,
          )
  
      return results_list
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import Tensor
  from mmdet.models.test_time_augs import merge_aug_masks
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.structures.bbox import bbox2roi
  from mmdet.utils import InstanceList, OptConfigType
  from ..layers import adaptive_avg_pool2d
  from ..task_modules.samplers import SamplingResult
  from ..utils import empty_instances, unpack_gt_instances
  from .cascade_roi_head import CascadeRoIHead
label_desc: Use image node_id 8 for calling the HybridTaskCascadeRoIHead obj's underlying member method code with example usage: obj.predict(x, rpn_results_list, batch_data_samples, rescale) and returns: results_list