class_docstr: Constructs a 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 [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
  
  Args:
      outputs ([`DetrForSegmentation`]):
          Raw outputs of the model.
      target_sizes (`List[Tuple[int, int]]`, *optional*, defaults to `None`):
          A list of tuples (`Tuple[int, int]`) containing the target size (height, width) of each image in the
          batch. 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.
docstr_tok: ["Converts","the","output","of","[","`","DetrForSegmentation","`","]","into","semantic","segmentation","maps",".","Only","supports","PyTorch",".","Args",":","outputs","(","[","`","DetrForSegmentation","`","]",")",":","Raw","outputs","of","the","model",".","target_sizes","(","`","List","[","Tuple","[","int",",","int","]","]","`",",","*","optional","*",",","defaults","to","`","None","`",")",":","A","list","of","tuples","(","`","Tuple","[","int",",","int","]","`",")","containing","the","target","size","(","height",",","width",")","of","each","image","in","the","batch",".","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: List[Tuple[int, int]] = None
  ):
      """
      Converts the output of [`DetrForSegmentation`] into semantic segmentation maps. Only supports PyTorch.
  
      Args:
          outputs ([`DetrForSegmentation`]):
              Raw outputs of the model.
          target_sizes (`List[Tuple[int, int]]`, *optional*, defaults to `None`):
              A list of tuples (`Tuple[int, int]`) containing the target size (height, width) of each image in the
              batch. 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.logits
      )  # [batch_size, num_queries, num_classes+1]
      masks_queries_logits = (
          outputs.pred_masks
      )  # [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 = 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 io
  import pathlib
  import warnings
  from collections import defaultdict
  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 17 for calling the DetrFeatureExtractor obj's underlying member method code with example usage: obj.post_process_semantic_segmentation(outputs, target_sizes) and returns: semantic_segmentation