class_docstr: Constructs a MaskFormer feature extractor. The feature extractor can be used to prepare image(s) and optional
  targets for the model.
  
  This feature extractor inherits from [`FeatureExtractionMixin`] 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)`.
      max_size (`int`, *optional*, defaults to 1333):
          The largest size an image dimension can have (otherwise it's capped). Only has an effect if `do_resize` is
          set to `True`.
      resample (`int`, *optional*, defaults to `PIL.Image.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`.
      size_divisibility (`int`, *optional*, defaults to 32):
          Some backbones need images divisible by a certain number. If not passed, it defaults to the value used in
          Swin Transformer.
      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`.
      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`.
docstr: Converts the output of [`MaskFormerForInstanceSegmentationOutput`] into image segmentation predictions. Only
  supports PyTorch.
  
  Args:
      outputs ([`MaskFormerForInstanceSegmentationOutput`]):
          The outputs from [`MaskFormerForInstanceSegmentation`].
  
      target_size (`Tuple[int, int]`, *optional*):
          If set, the `masks_queries_logits` will be resized to `target_size`.
  
  Returns:
      `torch.Tensor`:
          A tensor of shape (`batch_size, num_class_labels, height, width`).
docstr_tok: ["Converts","the","output","of","[","`","MaskFormerForInstanceSegmentationOutput","`","]","into","image","segmentation","predictions",".","Only","supports","PyTorch",".","Args",":","outputs","(","[","`","MaskFormerForInstanceSegmentationOutput","`","]",")",":","The","outputs","from","[","`","MaskFormerForInstanceSegmentation","`","]",".","target_size","(","`","Tuple","[","int",",","int","]","`",",","*","optional","*",")",":","If","set",",","the","`","masks_queries_logits","`","will","be","resized","to","`","target_size","`",".","Returns",":","`","torch.Tensor","`",":","A","tensor","of","shape","(","`","batch_size",",","num_class_labels",",","height",",","width","`",")","."]
code: def post_process_segmentation(
      self,
      outputs: "MaskFormerForInstanceSegmentationOutput",
      target_size: Tuple[int, int] = None,
  ) -> "torch.Tensor":
      """
      Converts the output of [`MaskFormerForInstanceSegmentationOutput`] into image segmentation predictions. Only
      supports PyTorch.
  
      Args:
          outputs ([`MaskFormerForInstanceSegmentationOutput`]):
              The outputs from [`MaskFormerForInstanceSegmentation`].
  
          target_size (`Tuple[int, int]`, *optional*):
              If set, the `masks_queries_logits` will be resized to `target_size`.
  
      Returns:
          `torch.Tensor`:
              A tensor of shape (`batch_size, num_class_labels, height, width`).
      """
      logger.warning(
          "`post_process_segmentation` is deprecated and will be removed in v5 of Transformers, please use"
          " `post_process_instance_segmentation`",
          FutureWarning,
      )
  
      # class_queries_logits has shape [BATCH, QUERIES, CLASSES + 1]
      class_queries_logits = outputs.class_queries_logits
      # masks_queries_logits has shape [BATCH, QUERIES, HEIGHT, WIDTH]
      masks_queries_logits = outputs.masks_queries_logits
      if target_size is not None:
          masks_queries_logits = interpolate(
              masks_queries_logits,
              size=target_size,
              mode="bilinear",
              align_corners=False,
          )
      # remove the null class `[..., :-1]`
      masks_classes = class_queries_logits.softmax(dim=-1)[..., :-1]
      # mask probs has shape [BATCH, QUERIES, HEIGHT, WIDTH]
      masks_probs = masks_queries_logits.sigmoid()
      # now we want to sum over the queries,
      # $ out_{c,h,w} =  \sum_q p_{q,c} * m_{q,h,w} $
      # where $ softmax(p) \in R^{q, c} $ is the mask classes
      # and $ sigmoid(m) \in R^{q, h, w}$ is the mask probabilities
      # b(atch)q(uery)c(lasses), b(atch)q(uery)h(eight)w(idth)
      segmentation = torch.einsum(
          "bqc, bqhw -> bchw", masks_classes, masks_probs
      )
  
      return segmentation
  
imports: from typing import TYPE_CHECKING, Dict, List, Optional, Set, Tuple, Union
  import numpy
  from PIL import Image
  from transformers.image_utils import PILImageResampling
  from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin
  from ...image_utils import ImageFeatureExtractionMixin, ImageInput, is_torch_tensor
  from ...utils import TensorType, is_torch_available, logging
label_desc: Use image node_id 7 for calling the MaskFormerFeatureExtractor obj's underlying member method code with example usage: obj.post_process_segmentation(outputs, target_size) and returns: segmentation