class_docstr: Constructs a Conditional Detr image processor.
  
  Args:
      format (`str`, *optional*, defaults to `"coco_detection"`):
          Data format of the annotations. One of "coco_detection" or "coco_panoptic".
      do_resize (`bool`, *optional*, defaults to `True`):
          Controls whether to resize the image's (height, width) dimensions to the specified `size`. Can be
          overridden by the `do_resize` parameter in the `preprocess` method.
      size (`Dict[str, int]` *optional*, defaults to `{"shortest_edge": 800, "longest_edge": 1333}`):
          Size of the image's (height, width) dimensions after resizing. Can be overridden by the `size` parameter in
          the `preprocess` method.
      resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BILINEAR`):
          Resampling filter to use if resizing the image.
      do_rescale (`bool`, *optional*, defaults to `True`):
          Controls whether to rescale the image by the specified scale `rescale_factor`. Can be overridden by the
          `do_rescale` parameter in the `preprocess` method.
      rescale_factor (`int` or `float`, *optional*, defaults to `1/255`):
          Scale factor to use if rescaling the image. Can be overridden by the `rescale_factor` parameter in the
          `preprocess` method.
      do_normalize:
          Controls whether to normalize the image. Can be overridden by the `do_normalize` parameter in the
          `preprocess` method.
      image_mean (`float` or `List[float]`, *optional*, defaults to `IMAGENET_DEFAULT_MEAN`):
          Mean values to use when normalizing the image. Can be a single value or a list of values, one for each
          channel. Can be overridden by the `image_mean` parameter in the `preprocess` method.
      image_std (`float` or `List[float]`, *optional*, defaults to `IMAGENET_DEFAULT_STD`):
          Standard deviation values to use when normalizing the image. Can be a single value or a list of values, one
          for each channel. Can be overridden by the `image_std` parameter in the `preprocess` method.
      do_pad (`bool`, *optional*, defaults to `True`):
          Controls whether to pad the image to the largest image in a batch and create a pixel mask. Can be
          overridden by the `do_pad` parameter in the `preprocess` method.
docstr: Converts the output of [`ConditionalDetrForSegmentation`] into image panoptic segmentation predictions. Only supports
  PyTorch.
  
  Args:
      outputs ([`ConditionalDetrForSegmentation`]):
          The outputs from [`ConditionalDetrForSegmentation`].
      threshold (`float`, *optional*, defaults to 0.5):
          The probability score threshold to keep predicted instance masks.
      mask_threshold (`float`, *optional*, defaults to 0.5):
          Threshold to use when turning the predicted masks into binary values.
      overlap_mask_area_threshold (`float`, *optional*, defaults to 0.8):
          The overlap mask area threshold to merge or discard small disconnected parts within each binary
          instance mask.
      label_ids_to_fuse (`Set[int]`, *optional*):
          The labels in this state will have all their instances be fused together. For instance we could say
          there can only be one sky in an image, but several persons, so the label ID for sky would be in that
          set, but not the one for person.
      target_sizes (`List[Tuple]`, *optional*):
          List of length (batch_size), where each list item (`Tuple[int, int]]`) corresponds to the requested
          final size (height, width) of each prediction in batch. If unset, predictions will not be resized.
  Returns:
      `List[Dict]`: A list of dictionaries, one per image, each dictionary containing two keys:
      - **segmentation** -- a tensor of shape `(height, width)` where each pixel represents a `segment_id` or
        `None` if no mask if found above `threshold`. If `target_sizes` is specified, segmentation is resized to
        the corresponding `target_sizes` entry.
      - **segments_info** -- A dictionary that contains additional information on each segment.
          - **id** -- an integer representing the `segment_id`.
          - **label_id** -- An integer representing the label / semantic class id corresponding to `segment_id`.
          - **was_fused** -- a boolean, `True` if `label_id` was in `label_ids_to_fuse`, `False` otherwise.
            Multiple instances of the same class / label were fused and assigned a single `segment_id`.
          - **score** -- Prediction score of segment with `segment_id`.
docstr_tok: ["Converts","the","output","of","[","`","ConditionalDetrForSegmentation","`","]","into","image","panoptic","segmentation","predictions",".","Only","supports","PyTorch",".","Args",":","outputs","(","[","`","ConditionalDetrForSegmentation","`","]",")",":","The","outputs","from","[","`","ConditionalDetrForSegmentation","`","]",".","threshold","(","`","float","`",",","*","optional","*",",","defaults","to","0.5",")",":","The","probability","score","threshold","to","keep","predicted","instance","masks",".","mask_threshold","(","`","float","`",",","*","optional","*",",","defaults","to","0.5",")",":","Threshold","to","use","when","turning","the","predicted","masks","into","binary","values",".","overlap_mask_area_threshold","(","`","float","`",",","*","optional","*",",","defaults","to","0.8",")",":","The","overlap","mask","area","threshold","to","merge","or","discard","small","disconnected","parts","within","each","binary","instance","mask",".","label_ids_to_fuse","(","`","Set","[","int","]","`",",","*","optional","*",")",":","The","labels","in","this","state","will","have","all","their","instances","be","fused","together",".","For","instance","we","could","say","there","can","only","be","one","sky","in","an","image",",","but","several","persons",",","so","the","label","ID","for","sky","would","be","in","that","set",",","but","not","the","one","for","person",".","target_sizes","(","`","List","[","Tuple","]","`",",","*","optional","*",")",":","List","of","length","(","batch_size",")",",","where","each","list","item","(","`","Tuple","[","int",",","int","]","]","`",")","corresponds","to","the","requested","final","size","(","height",",","width",")","of","each","prediction","in","batch",".","If","unset",",","predictions","will","not","be","resized",".","Returns",":","`","List","[","Dict","]","`",":","A","list","of","dictionaries",",","one","per","image",",","each","dictionary","containing","two","keys",":","-","*","*","segmentation","*","*","--","a","tensor","of","shape","`","(","height",",","width",")","`","where","each","pixel","represents","a","`","segment_id","`","or","`","None","`","if","no","mask","if","found","above","`","threshold","`",".","If","`","target_sizes","`","is","specified",",","segmentation","is","resized","to","the","corresponding","`","target_sizes","`","entry",".","-","*","*","segments_info","*","*","--","A","dictionary","that","contains","additional","information","on","each","segment",".","-","*","*","id","*","*","--","an","integer","representing","the","`","segment_id","`",".","-","*","*","label_id","*","*","--","An","integer","representing","the","label","\/","semantic","class","id","corresponding","to","`","segment_id","`",".","-","*","*","was_fused","*","*","--","a","boolean",",","`","True","`","if","`","label_id","`","was","in","`","label_ids_to_fuse","`",",","`","False","`","otherwise",".","Multiple","instances","of","the","same","class","\/","label","were","fused","and","assigned","a","single","`","segment_id","`",".","-","*","*","score","*","*","--","Prediction","score","of","segment","with","`","segment_id","`","."]
code: def post_process_panoptic_segmentation(
      self,
      outputs,
      threshold: float = 0.5,
      mask_threshold: float = 0.5,
      overlap_mask_area_threshold: float = 0.8,
      label_ids_to_fuse: Optional[Set[int]] = None,
      target_sizes: Optional[List[Tuple[int, int]]] = None,
  ) -> List[Dict]:
      """
      Converts the output of [`ConditionalDetrForSegmentation`] into image panoptic segmentation predictions. Only supports
      PyTorch.
  
      Args:
          outputs ([`ConditionalDetrForSegmentation`]):
              The outputs from [`ConditionalDetrForSegmentation`].
          threshold (`float`, *optional*, defaults to 0.5):
              The probability score threshold to keep predicted instance masks.
          mask_threshold (`float`, *optional*, defaults to 0.5):
              Threshold to use when turning the predicted masks into binary values.
          overlap_mask_area_threshold (`float`, *optional*, defaults to 0.8):
              The overlap mask area threshold to merge or discard small disconnected parts within each binary
              instance mask.
          label_ids_to_fuse (`Set[int]`, *optional*):
              The labels in this state will have all their instances be fused together. For instance we could say
              there can only be one sky in an image, but several persons, so the label ID for sky would be in that
              set, but not the one for person.
          target_sizes (`List[Tuple]`, *optional*):
              List of length (batch_size), where each list item (`Tuple[int, int]]`) corresponds to the requested
              final size (height, width) of each prediction in batch. If unset, predictions will not be resized.
      Returns:
          `List[Dict]`: A list of dictionaries, one per image, each dictionary containing two keys:
          - **segmentation** -- a tensor of shape `(height, width)` where each pixel represents a `segment_id` or
            `None` if no mask if found above `threshold`. If `target_sizes` is specified, segmentation is resized to
            the corresponding `target_sizes` entry.
          - **segments_info** -- A dictionary that contains additional information on each segment.
              - **id** -- an integer representing the `segment_id`.
              - **label_id** -- An integer representing the label / semantic class id corresponding to `segment_id`.
              - **was_fused** -- a boolean, `True` if `label_id` was in `label_ids_to_fuse`, `False` otherwise.
                Multiple instances of the same class / label were fused and assigned a single `segment_id`.
              - **score** -- Prediction score of segment with `segment_id`.
      """
  
      if label_ids_to_fuse is None:
          logger.warning_once(
              "`label_ids_to_fuse` unset. No instance will be fused."
          )
          label_ids_to_fuse = set()
  
      class_queries_logits = (
          outputs.logits
      )  # [batch_size, num_queries, num_classes+1]
      masks_queries_logits = (
          outputs.pred_masks
      )  # [batch_size, num_queries, height, width]
  
      batch_size = class_queries_logits.shape[0]
      num_labels = class_queries_logits.shape[-1] - 1
  
      mask_probs = (
          masks_queries_logits.sigmoid()
      )  # [batch_size, num_queries, height, width]
  
      # Predicted label and score of each query (batch_size, num_queries)
      pred_scores, pred_labels = nn.functional.softmax(
          class_queries_logits, dim=-1
      ).max(-1)
  
      # Loop over items in batch size
      results: List[Dict[str, TensorType]] = []
  
      for i in range(batch_size):
          (
              mask_probs_item,
              pred_scores_item,
              pred_labels_item,
          ) = remove_low_and_no_objects(
              mask_probs[i],
              pred_scores[i],
              pred_labels[i],
              threshold,
              num_labels,
          )
  
          # No mask found
          if mask_probs_item.shape[0] <= 0:
              height, width = (
                  target_sizes[i]
                  if target_sizes is not None
                  else mask_probs_item.shape[1:]
              )
              segmentation = torch.zeros((height, width)) - 1
              results.append(
                  {"segmentation": segmentation, "segments_info": []}
              )
              continue
  
          # Get segmentation map and segment information of batch item
          target_size = (
              target_sizes[i] if target_sizes is not None else None
          )
          segmentation, segments = compute_segments(
              mask_probs=mask_probs_item,
              pred_scores=pred_scores_item,
              pred_labels=pred_labels_item,
              mask_threshold=mask_threshold,
              overlap_mask_area_threshold=overlap_mask_area_threshold,
              label_ids_to_fuse=label_ids_to_fuse,
              target_size=target_size,
          )
  
          results.append(
              {"segmentation": segmentation, "segments_info": segments}
          )
      return results
  
imports: import io
  import pathlib
  from collections import defaultdict
  from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Union
  import numpy
  from ...feature_extraction_utils import BatchFeature
  from ...image_processing_utils import BaseImageProcessor, get_size_dict
  from ...image_transforms import PaddingMode, center_to_corners_format, corners_to_center_format, id_to_rgb, pad, rescale, resize, rgb_to_id, to_channel_dimension_format
  from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, AnnotationFormat, AnnotationType, ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_list_of_images, to_numpy_array, valid_images, validate_annotations
  from ...utils import TensorType, is_flax_available, is_jax_tensor, is_scipy_available, is_tf_available, is_tf_tensor, is_torch_available, is_torch_tensor, is_vision_available, logging
label_desc: Use image node_id 19 for calling the ConditionalDetrImageProcessor obj's underlying member method code with example usage: obj.post_process_panoptic_segmentation(outputs, threshold, mask_threshold, overlap_mask_area_threshold, label_ids_to_fuse, target_sizes) and returns: results