class_docstr: A semantic segmentation head described in :paper:`Panoptic-DeepLab`.
docstr: Returns:
      In training, returns (None, dict of losses)
      In inference, returns (CxHxW logits, {})
docstr_tok: ["Returns",":","In","training",",","returns","(","None",",","dict","of","losses",")","In","inference",",","returns","(","CxHxW","logits",",","{","}",")"]
code: def forward(self, features, targets=None, weights=None):
      """
      Returns:
          In training, returns (None, dict of losses)
          In inference, returns (CxHxW logits, {})
      """
      y = self.layers(features)
      if self.training:
          return None, self.losses(y, targets, weights)
      else:
          y = F.interpolate(
              y,
              scale_factor=self.common_stride,
              mode="bilinear",
              align_corners=False,
          )
          return y, {}
  
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 3 for calling the PanopticDeepLabSemSegHead obj's underlying member method code with example usage: obj.forward(features, targets, weights) and returns: None,  self, y,  dict