class_docstr: Main class for semantic segmentation architectures.
class_docstr_tok: ["Main","class","for","semantic","segmentation","architectures","."]
docstr: Args:
      batched_inputs: a list, batched outputs of :class:`DatasetMapper`.
          Each item in the list contains the inputs for one image.
  
          For now, each item in the list is a dict that contains:
  
             * "image": Tensor, image in (C, H, W) format.
             * "sem_seg": semantic segmentation ground truth
             * Other information that's included in the original dicts, such as:
               "height", "width" (int): the output resolution of the model (may be different
               from input resolution), used in inference.
  
  
  Returns:
      list[dict]:
        Each dict is the output for one input image.
        The dict contains one key "sem_seg" whose value is a
        Tensor that represents the
        per-pixel segmentation prediced by the head.
        The prediction has shape KxHxW that represents the logits of
        each class for each pixel.
docstr_tok: ["Args",":","batched_inputs",":","a","list",",","batched","outputs","of",":","class",":","`","DatasetMapper","`",".","Each","item","in","the","list","contains","the","inputs","for","one","image",".","For","now",",","each","item","in","the","list","is","a","dict","that","contains",":","*","``","image","''",":","Tensor",",","image","in","(","C",",","H",",","W",")","format",".","*","``","sem_seg","''",":","semantic","segmentation","ground","truth","*","Other","information","that","'s","included","in","the","original","dicts",",","such","as",":","``","height","''",",","``","width","''","(","int",")",":","the","output","resolution","of","the","model","(","may","be","different","from","input","resolution",")",",","used","in","inference",".","Returns",":","list","[","dict","]",":","Each","dict","is","the","output","for","one","input","image",".","The","dict","contains","one","key","``","sem_seg","''","whose","value","is","a","Tensor","that","represents","the","per-pixel","segmentation","prediced","by","the","head",".","The","prediction","has","shape","KxHxW","that","represents","the","logits","of","each","class","for","each","pixel","."]
code: def forward(self, batched_inputs):
      """
      Args:
          batched_inputs: a list, batched outputs of :class:`DatasetMapper`.
              Each item in the list contains the inputs for one image.
  
              For now, each item in the list is a dict that contains:
  
                 * "image": Tensor, image in (C, H, W) format.
                 * "sem_seg": semantic segmentation ground truth
                 * Other information that's included in the original dicts, such as:
                   "height", "width" (int): the output resolution of the model (may be different
                   from input resolution), used in inference.
  
  
      Returns:
          list[dict]:
            Each dict is the output for one input image.
            The dict contains one key "sem_seg" whose value is a
            Tensor that represents the
            per-pixel segmentation prediced by the head.
            The prediction has shape KxHxW that represents the logits of
            each class for each pixel.
      """
      images = [x["image"].to(self.device) for x in batched_inputs]
      images = [(x - self.pixel_mean) / self.pixel_std for x in images]
      images = ImageList.from_tensors(
          images,
          self.backbone.size_divisibility,
          padding_constraints=self.backbone.padding_constraints,
      )
  
      features = self.backbone(images.tensor)
  
      if "sem_seg" in batched_inputs[0]:
          targets = [
              x["sem_seg"].to(self.device) for x in batched_inputs
          ]
          targets = ImageList.from_tensors(
              targets,
              self.backbone.size_divisibility,
              self.sem_seg_head.ignore_value,
              self.backbone.padding_constraints,
          ).tensor
      else:
          targets = None
      results, losses = self.sem_seg_head(features, targets)
  
      if self.training:
          return losses
  
      processed_results = []
      for result, input_per_image, image_size in zip(
          results, batched_inputs, images.image_sizes
      ):
          height = input_per_image.get("height", image_size[0])
          width = input_per_image.get("width", image_size[1])
          r = sem_seg_postprocess(result, image_size, height, width)
          processed_results.append({"sem_seg": r})
      return processed_results
  
imports: import numpy
  from typing import Callable, Dict, Optional, Tuple, Union
  import fvcore.nn.weight_init
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.layers import Conv2d, ShapeSpec, get_norm
  from detectron2.structures import ImageList
  from detectron2.utils.registry import Registry
  from ..backbone import Backbone, build_backbone
  from ..postprocessing import sem_seg_postprocess
  from .build import META_ARCH_REGISTRY
label_desc: Use image node_id 4 for calling the SemanticSegmentor obj's underlying member method code with example usage: obj.forward(batched_inputs) and returns: processed_results, losses