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: Resize the image to the given size. Size can be min_size (scalar) or (w, h) tuple. If size is an int, smaller
  edge of the image will be matched to this number.
  
  If given, also resize the target accordingly.
docstr_tok: ["Resize","the","image","to","the","given","size",".","Size","can","be","min_size","(","scalar",")","or","(","w",",","h",")","tuple",".","If","size","is","an","int",",","smaller","edge","of","the","image","will","be","matched","to","this","number",".","If","given",",","also","resize","the","target","accordingly","."]
code: def _resize(self, image, size, target=None, max_size=None):
      """
      Resize the image to the given size. Size can be min_size (scalar) or (w, h) tuple. If size is an int, smaller
      edge of the image will be matched to this number.
  
      If given, also resize the target accordingly.
      """
      if not isinstance(image, Image.Image):
          image = self.to_pil_image(image)
  
      def get_size_with_aspect_ratio(image_size, size, max_size=None):
          w, h = image_size
          if max_size is not None:
              min_original_size = float(min((w, h)))
              max_original_size = float(max((w, h)))
              if (
                  max_original_size / min_original_size * size
                  > max_size
              ):
                  size = int(
                      round(
                          max_size
                          * min_original_size
                          / max_original_size
                      )
                  )
  
          if (w <= h and w == size) or (h <= w and h == size):
              return (h, w)
  
          if w < h:
              ow = size
              oh = int(size * h / w)
          else:
              oh = size
              ow = int(size * w / h)
  
          return (oh, ow)
  
      def get_size(image_size, size, max_size=None):
          if isinstance(size, (list, tuple)):
              return size
          else:
              # size returned must be (w, h) since we use PIL to resize images
              # so we revert the tuple
              return get_size_with_aspect_ratio(
                  image_size, size, max_size
              )[::-1]
  
      size = get_size(image.size, size, max_size)
      rescaled_image = self.resize(image, size=size)
  
      if target is None:
          return rescaled_image, None
  
      ratios = tuple(
          float(s) / float(s_orig)
          for s, s_orig in zip(rescaled_image.size, image.size)
      )
      ratio_width, ratio_height = ratios
  
      target = target.copy()
      if "boxes" in target:
          boxes = target["boxes"]
          scaled_boxes = boxes * np.asarray(
              [ratio_width, ratio_height, ratio_width, ratio_height],
              dtype=np.float32,
          )
          target["boxes"] = scaled_boxes
  
      if "area" in target:
          area = target["area"]
          scaled_area = area * (ratio_width * ratio_height)
          target["area"] = scaled_area
  
      w, h = size
      target["size"] = np.asarray([h, w], dtype=np.int64)
  
      if "masks" in target:
          # use PyTorch as current workaround
          # TODO replace by self.resize
          masks = torch.from_numpy(target["masks"][:, None]).float()
          interpolated_masks = (
              nn.functional.interpolate(
                  masks, size=(h, w), mode="nearest"
              )[:, 0]
              > 0.5
          )
          target["masks"] = interpolated_masks.numpy()
  
      return rescaled_image, target
  
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 7 for calling the ConditionalDetrFeatureExtractor obj's underlying member method code with example usage: obj._resize(image, size, target, max_size) and returns: rescaled_image,  target, oh,  ow, rescaled_image,  None, h,  w, size, get_size_with_aspect_ratio