class_docstr: A semantic segmentation head described in :paper:`Panoptic-DeepLab`.
docstr: NOTE: this interface is experimental.
  
  Args:
      input_shape (ShapeSpec): shape of the input feature
      decoder_channels (list[int]): a list of output channels of each
          decoder stage. It should have the same length as "input_shape"
          (each element in "input_shape" corresponds to one decoder stage).
      norm (str or callable): normalization for all conv layers.
      head_channels (int): the output channels of extra convolutions
          between decoder and predictor.
      loss_weight (float): loss weight.
      loss_top_k: (float): setting the top k% hardest pixels for
          "hard_pixel_mining" loss.
      loss_type, ignore_value, num_classes: the same as the base class.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","input_shape","(","ShapeSpec",")",":","shape","of","the","input","feature","decoder_channels","(","list","[","int","]",")",":","a","list","of","output","channels","of","each","decoder","stage",".","It","should","have","the","same","length","as","``","input_shape","''","(","each","element","in","``","input_shape","''","corresponds","to","one","decoder","stage",")",".","norm","(","str","or","callable",")",":","normalization","for","all","conv","layers",".","head_channels","(","int",")",":","the","output","channels","of","extra","convolutions","between","decoder","and","predictor",".","loss_weight","(","float",")",":","loss","weight",".","loss_top_k",":","(","float",")",":","setting","the","top","k","%","hardest","pixels","for","``","hard_pixel_mining","''","loss",".","loss_type",",","ignore_value",",","num_classes",":","the","same","as","the","base","class","."]
code: def __init__(
      self,
      input_shape: Dict[str, ShapeSpec],
      *,
      decoder_channels: List[int],
      norm: Union[str, Callable],
      head_channels: int,
      loss_weight: float,
      loss_type: str,
      loss_top_k: float,
      ignore_value: int,
      num_classes: int,
      **kwargs,
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          input_shape (ShapeSpec): shape of the input feature
          decoder_channels (list[int]): a list of output channels of each
              decoder stage. It should have the same length as "input_shape"
              (each element in "input_shape" corresponds to one decoder stage).
          norm (str or callable): normalization for all conv layers.
          head_channels (int): the output channels of extra convolutions
              between decoder and predictor.
          loss_weight (float): loss weight.
          loss_top_k: (float): setting the top k% hardest pixels for
              "hard_pixel_mining" loss.
          loss_type, ignore_value, num_classes: the same as the base class.
      """
      super().__init__(
          input_shape,
          decoder_channels=decoder_channels,
          norm=norm,
          ignore_value=ignore_value,
          **kwargs,
      )
      assert self.decoder_only
  
      self.loss_weight = loss_weight
      use_bias = norm == ""
      # `head` is additional transform before predictor
      if self.use_depthwise_separable_conv:
          # We use a single 5x5 DepthwiseSeparableConv2d to replace
          # 2 3x3 Conv2d since they have the same receptive field.
          self.head = DepthwiseSeparableConv2d(
              decoder_channels[0],
              head_channels,
              kernel_size=5,
              padding=2,
              norm1=norm,
              activation1=F.relu,
              norm2=norm,
              activation2=F.relu,
          )
      else:
          self.head = nn.Sequential(
              Conv2d(
                  decoder_channels[0],
                  decoder_channels[0],
                  kernel_size=3,
                  padding=1,
                  bias=use_bias,
                  norm=get_norm(norm, decoder_channels[0]),
                  activation=F.relu,
              ),
              Conv2d(
                  decoder_channels[0],
                  head_channels,
                  kernel_size=3,
                  padding=1,
                  bias=use_bias,
                  norm=get_norm(norm, head_channels),
                  activation=F.relu,
              ),
          )
          weight_init.c2_xavier_fill(self.head[0])
          weight_init.c2_xavier_fill(self.head[1])
      self.predictor = Conv2d(head_channels, num_classes, kernel_size=1)
      nn.init.normal_(self.predictor.weight, 0, 0.001)
      nn.init.constant_(self.predictor.bias, 0)
  
      if loss_type == "cross_entropy":
          self.loss = nn.CrossEntropyLoss(
              reduction="mean", ignore_index=ignore_value
          )
      elif loss_type == "hard_pixel_mining":
          self.loss = DeepLabCE(
              ignore_label=ignore_value, top_k_percent_pixels=loss_top_k
          )
      else:
          raise ValueError("Unexpected loss type: %s" % loss_type)
  
imports: import numpy
  from typing import Callable, Dict, List, Union
  import fvcore.nn.weight_init
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.data import MetadataCatalog
  from detectron2.layers import Conv2d, DepthwiseSeparableConv2d, ShapeSpec, get_norm
  from detectron2.modeling import META_ARCH_REGISTRY, SEM_SEG_HEADS_REGISTRY, build_backbone, build_sem_seg_head
  from detectron2.modeling.postprocessing import sem_seg_postprocess
  from detectron2.projects.deeplab import DeepLabV3PlusHead
  from detectron2.projects.deeplab.loss import DeepLabCE
  from detectron2.structures import BitMasks, ImageList, Instances
  from detectron2.utils.registry import Registry
  from .post_processing import get_panoptic_segmentation
label_desc: Use image node_id 1 to create a new PanopticDeepLabSemSegHead object from inherited base classes: DeepLabV3PlusHead with example: obj = PanopticDeepLabSemSegHead(input_shape)