class_docstr: Base class of Two-stage Panoptic Segmentor.
  
  As well as the components in TwoStageDetector, Panoptic Segmentor has extra
  semantic_head and panoptic_fusion_head.
class_docstr_tok: ["Base","class","of","Two-stage","Panoptic","Segmentor",".","As","well","as","the","components","in","TwoStageDetector",",","Panoptic","Segmentor","has","extra","semantic_head","and","panoptic_fusion_head","."]
code: def __init__(
      self,
      backbone: ConfigType,
      neck: OptConfigType = None,
      rpn_head: OptConfigType = None,
      roi_head: OptConfigType = None,
      train_cfg: OptConfigType = None,
      test_cfg: OptConfigType = None,
      data_preprocessor: OptConfigType = None,
      init_cfg: OptMultiConfig = None,
      # for panoptic segmentation
      semantic_head: OptConfigType = None,
      panoptic_fusion_head: OptConfigType = None,
  ) -> None:
      super().__init__(
          backbone=backbone,
          neck=neck,
          rpn_head=rpn_head,
          roi_head=roi_head,
          train_cfg=train_cfg,
          test_cfg=test_cfg,
          data_preprocessor=data_preprocessor,
          init_cfg=init_cfg,
      )
  
      if semantic_head is not None:
          self.semantic_head = MODELS.build(semantic_head)
  
      if panoptic_fusion_head is not None:
          panoptic_cfg = (
              test_cfg.panoptic if test_cfg is not None else None
          )
          panoptic_fusion_head_ = panoptic_fusion_head.deepcopy()
          panoptic_fusion_head_.update(test_cfg=panoptic_cfg)
          self.panoptic_fusion_head = MODELS.build(
              panoptic_fusion_head_
          )
  
          self.num_things_classes = (
              self.panoptic_fusion_head.num_things_classes
          )
          self.num_stuff_classes = (
              self.panoptic_fusion_head.num_stuff_classes
          )
          self.num_classes = self.panoptic_fusion_head.num_classes
  
file_path: mmdetection/mmdet/models/detectors/panoptic_two_stage_segmentor.py
imports: import copy
  from typing import List
  import torch
  from mmengine.structures import PixelData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.structures import SampleList
  from mmdet.utils import ConfigType, OptConfigType, OptMultiConfig
  from .two_stage import TwoStageDetector
label_desc: Use image node_id 1 to create a new TwoStagePanopticSegmentor object from inherited base classes: TwoStageDetector with example: obj = TwoStagePanopticSegmentor(backbone, neck, rpn_head, roi_head, train_cfg, test_cfg, data_preprocessor, init_cfg, semantic_head, panoptic_fusion_head)