class_docstr: Constructs a Conditional DETR feature extractor.
  
  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:
      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`):
          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`.
      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.
class_docstr_tok: ["Constructs","a","Conditional","DETR","feature","extractor",".","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",":","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","`",")",":","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","`",".","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","."]
docstr: Converts the output of [`ConditionalDetrForSegmentation`] into instance segmentation predictions. Only supports
  PyTorch.
  
  Args:
      outputs ([`ConditionalDetrForSegmentation`]):
          Raw outputs of the model.
      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.
      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. If left to None, predictions will not be resized.
      return_coco_annotation (`bool`, *optional*):
          Defaults to `False`. If set to `True`, segmentation maps are returned in COCO run-length encoding (RLE)
          format.
  
  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
        `List[List]` run-length encoding (RLE) of the segmentation map if return_coco_annotation is set to
        `True`. Set to `None` if no mask if found above `threshold`.
      - **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`.
          - **score** -- Prediction score of segment with `segment_id`.
docstr_tok: ["Converts","the","output","of","[","`","ConditionalDetrForSegmentation","`","]","into","instance","segmentation","predictions",".","Only","supports","PyTorch",".","Args",":","outputs","(","[","`","ConditionalDetrForSegmentation","`","]",")",":","Raw","outputs","of","the","model",".","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",".","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",".","If","left","to","None",",","predictions","will","not","be","resized",".","return_coco_annotation","(","`","bool","`",",","*","optional","*",")",":","Defaults","to","`","False","`",".","If","set","to","`","True","`",",","segmentation","maps","are","returned","in","COCO","run-length","encoding","(","RLE",")","format",".","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","`","List","[","List","]","`","run-length","encoding","(","RLE",")","of","the","segmentation","map","if","return_coco_annotation","is","set","to","`","True","`",".","Set","to","`","None","`","if","no","mask","if","found","above","`","threshold","`",".","-","*","*","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","`",".","-","*","*","score","*","*","--","Prediction","score","of","segment","with","`","segment_id","`","."]
code: def post_process_instance_segmentation(
      self,
      outputs,
      threshold: float = 0.5,
      mask_threshold: float = 0.5,
      overlap_mask_area_threshold: float = 0.8,
      target_sizes: Optional[List[Tuple[int, int]]] = None,
      return_coco_annotation: Optional[bool] = False,
  ) -> List[Dict]:
      """
      Converts the output of [`ConditionalDetrForSegmentation`] into instance segmentation predictions. Only supports
      PyTorch.
  
      Args:
          outputs ([`ConditionalDetrForSegmentation`]):
              Raw outputs of the model.
          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.
          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. If left to None, predictions will not be resized.
          return_coco_annotation (`bool`, *optional*):
              Defaults to `False`. If set to `True`, segmentation maps are returned in COCO run-length encoding (RLE)
              format.
  
      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
            `List[List]` run-length encoding (RLE) of the segmentation map if return_coco_annotation is set to
            `True`. Set to `None` if no mask if found above `threshold`.
          - **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`.
              - **score** -- Prediction score of segment with `segment_id`.
      """
      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=[],
              target_size=target_size,
          )
  
          # Return segmentation map in run-length encoding (RLE) format
          if return_coco_annotation:
              segmentation = convert_segmentation_to_rle(segmentation)
  
          results.append(
              {"segmentation": segmentation, "segments_info": segments}
          )
      return results
  
imports: import pathlib
  import warnings
  from typing import Dict, List, Optional, Set, Tuple, Union
  import numpy
  from PIL import Image
  from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin
  from ...image_utils import ImageFeatureExtractionMixin, is_torch_tensor
  from ...utils import TensorType, is_torch_available, logging
label_desc: Use image node_id 15 for calling the ConditionalDetrFeatureExtractor obj's underlying member method code with example usage: obj.post_process_instance_segmentation(outputs, threshold, mask_threshold, overlap_mask_area_threshold, target_sizes, return_coco_annotation) and returns: results