class_docstr: Constructs a OneFormer image processor. The image processor can be used to prepare image(s), task input(s) and
  optional text inputs and targets for the model.
  
  This image processor inherits from [`BaseImageProcessor`] which contains most of the main methods. Users should
  refer to this superclass for more information regarding those methods.
  
  Args:
      do_resize (`bool`, *optional*, defaults to `True`):
          Whether to resize the input to a certain `size`.
      size (`int`, *optional*, defaults to 800):
          Resize the input to the given size. Only has an effect if `do_resize` is set to `True`. If size is a
          sequence like `(width, height)`, output size will be matched to this. If size is an int, smaller edge of
          the image will be matched to this number. i.e, if `height > width`, then image will be rescaled to `(size *
          height / width, size)`.
      resample (`int`, *optional*, defaults to `Resampling.BILINEAR`):
          An optional resampling filter. This can be one of `PIL.Image.Resampling.NEAREST`,
          `PIL.Image.Resampling.BOX`, `PIL.Image.Resampling.BILINEAR`, `PIL.Image.Resampling.HAMMING`,
          `PIL.Image.Resampling.BICUBIC` or `PIL.Image.Resampling.LANCZOS`. Only has an effect if `do_resize` is set
          to `True`.
      do_rescale (`bool`, *optional*, defaults to `True`):
          Whether to rescale the input to a certain `scale`.
      rescale_factor (`float`, *optional*, defaults to `1/ 255`):
          Rescale the input by the given factor. Only has an effect if `do_rescale` is set to `True`.
      do_normalize (`bool`, *optional*, defaults to `True`):
          Whether or not to normalize the input with mean and standard deviation.
      image_mean (`int`, *optional*, defaults to `[0.485, 0.456, 0.406]`):
          The sequence of means for each channel, to be used when normalizing images. Defaults to the ImageNet mean.
      image_std (`int`, *optional*, defaults to `[0.229, 0.224, 0.225]`):
          The sequence of standard deviations for each channel, to be used when normalizing images. Defaults to the
          ImageNet std.
      ignore_index (`int`, *optional*):
          Label to be assigned to background pixels in segmentation maps. If provided, segmentation map pixels
          denoted with 0 (background) will be replaced with `ignore_index`.
      do_reduce_labels (`bool`, *optional*, defaults to `False`):
          Whether or not to decrement all label values of segmentation maps by 1. Usually used for datasets where 0
          is used for background, and background itself is not included in all classes of a dataset (e.g. ADE20k).
          The background label will be replaced by `ignore_index`.
      repo_path (`str`, *optional*, defaults to `"shi-labs/oneformer_demo"`):
          Path to hub repo or local directory containing the JSON file with class information for the dataset.
          If unset, will look for `class_info_file` in the current working directory.
      class_info_file (`str`, *optional*):
          JSON file containing class information for the dataset. See `shi-labs/oneformer_demo/cityscapes_panoptic.json` for an example.
      num_text (`int`, *optional*):
          Number of text entries in the text input list.
class_docstr_tok: ["Constructs","a","OneFormer","image","processor",".","The","image","processor","can","be","used","to","prepare","image","(","s",")",",","task","input","(","s",")","and","optional","text","inputs","and","targets","for","the","model",".","This","image","processor","inherits","from","[","`","BaseImageProcessor","`","]","which","contains","most","of","the","main","methods",".","Users","should","refer","to","this","superclass","for","more","information","regarding","those","methods",".","Args",":","do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","resize","the","input","to","a","certain","`","size","`",".","size","(","`","int","`",",","*","optional","*",",","defaults","to","800",")",":","Resize","the","input","to","the","given","size",".","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","If","size","is","a","sequence","like","`","(","width",",","height",")","`",",","output","size","will","be","matched","to","this",".","If","size","is","an","int",",","smaller","edge","of","the","image","will","be","matched","to","this","number",".","i.e",",","if","`","height",">","width","`",",","then","image","will","be","rescaled","to","`","(","size","*","height","\/","width",",","size",")","`",".","resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","Resampling.BILINEAR","`",")",":","An","optional","resampling","filter",".","This","can","be","one","of","`","PIL.Image.Resampling.NEAREST","`",",","`","PIL.Image.Resampling.BOX","`",",","`","PIL.Image.Resampling.BILINEAR","`",",","`","PIL.Image.Resampling.HAMMING","`",",","`","PIL.Image.Resampling.BICUBIC","`","or","`","PIL.Image.Resampling.LANCZOS","`",".","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","do_rescale","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","rescale","the","input","to","a","certain","`","scale","`",".","rescale_factor","(","`","float","`",",","*","optional","*",",","defaults","to","`","1\/","255","`",")",":","Rescale","the","input","by","the","given","factor",".","Only","has","an","effect","if","`","do_rescale","`","is","set","to","`","True","`",".","do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","normalize","the","input","with","mean","and","standard","deviation",".","image_mean","(","`","int","`",",","*","optional","*",",","defaults","to","`","[","0.485",",","0.456",",","0.406","]","`",")",":","The","sequence","of","means","for","each","channel",",","to","be","used","when","normalizing","images",".","Defaults","to","the","ImageNet","mean",".","image_std","(","`","int","`",",","*","optional","*",",","defaults","to","`","[","0.229",",","0.224",",","0.225","]","`",")",":","The","sequence","of","standard","deviations","for","each","channel",",","to","be","used","when","normalizing","images",".","Defaults","to","the","ImageNet","std",".","ignore_index","(","`","int","`",",","*","optional","*",")",":","Label","to","be","assigned","to","background","pixels","in","segmentation","maps",".","If","provided",",","segmentation","map","pixels","denoted","with","0","(","background",")","will","be","replaced","with","`","ignore_index","`",".","do_reduce_labels","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","or","not","to","decrement","all","label","values","of","segmentation","maps","by","1",".","Usually","used","for","datasets","where","0","is","used","for","background",",","and","background","itself","is","not","included","in","all","classes","of","a","dataset","(","e.g",".","ADE20k",")",".","The","background","label","will","be","replaced","by","`","ignore_index","`",".","repo_path","(","`","str","`",",","*","optional","*",",","defaults","to","`","``","shi-labs\/oneformer_demo","''","`",")",":","Path","to","hub","repo","or","local","directory","containing","the","JSON","file","with","class","information","for","the","dataset",".","If","unset",",","will","look","for","`","class_info_file","`","in","the","current","working","directory",".","class_info_file","(","`","str","`",",","*","optional","*",")",":","JSON","file","containing","class","information","for","the","dataset",".","See","`","shi-labs\/oneformer_demo\/cityscapes_panoptic.json","`","for","an","example",".","num_text","(","`","int","`",",","*","optional","*",")",":","Number","of","text","entries","in","the","text","input","list","."]
docstr: Converts the output of [`MaskFormerForInstanceSegmentation`] into semantic segmentation maps. Only supports
  PyTorch.
  
  Args:
      outputs ([`MaskFormerForInstanceSegmentation`]):
          Raw outputs of the model.
      target_sizes (`List[Tuple[int, int]]`, *optional*):
          List of length (batch_size), where each list item (`Tuple[int, int]]`) corresponds to the requested
          final size (height, width) of each prediction. If left to None, predictions will not be resized.
  Returns:
      `List[torch.Tensor]`:
          A list of length `batch_size`, where each item is a semantic segmentation map of shape (height, width)
          corresponding to the target_sizes entry (if `target_sizes` is specified). Each entry of each
          `torch.Tensor` correspond to a semantic class id.
code: def post_process_semantic_segmentation(
      self,
      outputs,
      target_sizes: Optional[List[Tuple[int, int]]] = None,
  ) -> "torch.Tensor":
      """
      Converts the output of [`MaskFormerForInstanceSegmentation`] into semantic segmentation maps. Only supports
      PyTorch.
  
      Args:
          outputs ([`MaskFormerForInstanceSegmentation`]):
              Raw outputs of the model.
          target_sizes (`List[Tuple[int, int]]`, *optional*):
              List of length (batch_size), where each list item (`Tuple[int, int]]`) corresponds to the requested
              final size (height, width) of each prediction. If left to None, predictions will not be resized.
      Returns:
          `List[torch.Tensor]`:
              A list of length `batch_size`, where each item is a semantic segmentation map of shape (height, width)
              corresponding to the target_sizes entry (if `target_sizes` is specified). Each entry of each
              `torch.Tensor` correspond to a semantic class id.
      """
      class_queries_logits = (
          outputs.class_queries_logits
      )  # [batch_size, num_queries, num_classes+1]
      masks_queries_logits = (
          outputs.masks_queries_logits
      )  # [batch_size, num_queries, height, width]
  
      # Remove the null class `[..., :-1]`
      masks_classes = class_queries_logits.softmax(dim=-1)[..., :-1]
      masks_probs = (
          masks_queries_logits.sigmoid()
      )  # [batch_size, num_queries, height, width]
  
      # Semantic segmentation logits of shape (batch_size, num_classes, height, width)
      segmentation = torch.einsum(
          "bqc, bqhw -> bchw", masks_classes, masks_probs
      )
      batch_size = class_queries_logits.shape[0]
  
      # Resize logits and compute semantic segmentation maps
      if target_sizes is not None:
          if batch_size != len(target_sizes):
              raise ValueError(
                  "Make sure that you pass in as many target sizes as the batch dimension of the logits"
              )
  
          semantic_segmentation = []
          for idx in range(batch_size):
              resized_logits = torch.nn.functional.interpolate(
                  segmentation[idx].unsqueeze(dim=0),
                  size=target_sizes[idx],
                  mode="bilinear",
                  align_corners=False,
              )
              semantic_map = resized_logits[0].argmax(dim=0)
              semantic_segmentation.append(semantic_map)
      else:
          semantic_segmentation = segmentation.argmax(dim=1)
          semantic_segmentation = [
              semantic_segmentation[i]
              for i in range(semantic_segmentation.shape[0])
          ]
  
      return semantic_segmentation
  
imports: import json
  import os
  import warnings
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union
  import numpy
  from huggingface_hub import hf_hub_download
  from huggingface_hub.utils import RepositoryNotFoundError
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import PaddingMode, get_resize_output_image_size, pad, rescale, resize, to_channel_dimension_format
  from ...image_utils import ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_list_of_images, to_numpy_array, valid_images
  from ...utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, TensorType, is_torch_available, is_torch_tensor, logging
label_desc: Use image node_id 16 for calling the OneFormerImageProcessor obj's underlying member method code with example usage: obj.post_process_semantic_segmentation(outputs, target_sizes) and returns: semantic_segmentation