code: def __init__(
      self,
      num_stages=6,
      bbox_roi_extractor=_get_class_default_kwargs(RoIAlign),
      mask_roi_extractor=_get_class_default_kwargs(RoIAlign),
      bbox_head="DIIHead",
      mask_head="DynamicMaskHead",
      loss_func="QueryInstLoss",
  ):
      super(SparseRoIHead, self).__init__()
  
      self.num_stages = num_stages
  
      self.bbox_roi_extractor = bbox_roi_extractor
      self.mask_roi_extractor = mask_roi_extractor
      if isinstance(bbox_roi_extractor, dict):
          self.bbox_roi_extractor = RoIAlign(**bbox_roi_extractor)
      if isinstance(mask_roi_extractor, dict):
          self.mask_roi_extractor = RoIAlign(**mask_roi_extractor)
  
      self.bbox_heads = nn.LayerList(
          [copy.deepcopy(bbox_head) for _ in range(num_stages)]
      )
      self.mask_heads = nn.LayerList(
          [copy.deepcopy(mask_head) for _ in range(num_stages)]
      )
  
      self.loss_helper = loss_func
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import paddle
  from paddle import nn
  from ppdet.core.workspace import register
  from ppdet.modeling import initializer
  from .roi_extractor import RoIAlign
  from ..bbox_utils import delta2bbox_v2
  from ..cls_utils import _get_class_default_kwargs
  from ..layers import MultiHeadAttention
label_desc: Use image node_id 1 to create a new SparseRoIHead object from inherited base classes: nn with example: obj = SparseRoIHead(num_stages, bbox_roi_extractor, mask_roi_extractor, bbox_head, mask_head, loss_func)