class_docstr: Constructs a Mask2Former image processor. The image processor can be used to prepare image(s) and optional targets
  for the model.
  
  This image processor inherits from [`BaseImageProcessor`] 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)`.
      size_divisor (`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.
      resample (`int`, *optional*, defaults to `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`.
      do_rescale (`bool`, *optional*, defaults to `True`):
          Whether to rescale the input to a certain `scale`.
      rescale_factor (`float`, *optional*, defaults to `1/ 255`):
          Rescale the input by the given factor. Only has an effect if `do_rescale` 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.
      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: Resize the image to the given size. Size can be min_size (scalar) or `(height, width)` tuple. If size is an
  int, smaller edge of the image will be matched to this number.
  
  Args:
      image (`np.ndarray`):
          Image to resize.
      size (`Dict[str, int]`):
          The size of the output image.
      size_divisor (`int`, *optional*, defaults to 0):
          If `size_divisor` is given, the output image size will be divisible by the number.
      resample (`PILImageResampling` resampling filter, *optional*, defaults to `PILImageResampling.BILINEAR`):
          Resampling filter to use when resizing the image.
      data_format (`ChannelDimension` or `str`, *optional*):
          The channel dimension format for the output image. If unset, the channel dimension format of the input
          image is used.
      input_data_format (`ChannelDimension` or `str`, *optional*):
          The channel dimension format of the input image. If not provided, it will be inferred.
docstr_tok: ["Resize","the","image","to","the","given","size",".","Size","can","be","min_size","(","scalar",")","or","`","(","height",",","width",")","`","tuple",".","If","size","is","an","int",",","smaller","edge","of","the","image","will","be","matched","to","this","number",".","Args",":","image","(","`","np.ndarray","`",")",":","Image","to","resize",".","size","(","`","Dict","[","str",",","int","]","`",")",":","The","size","of","the","output","image",".","size_divisor","(","`","int","`",",","*","optional","*",",","defaults","to","0",")",":","If","`","size_divisor","`","is","given",",","the","output","image","size","will","be","divisible","by","the","number",".","resample","(","`","PILImageResampling","`","resampling","filter",",","*","optional","*",",","defaults","to","`","PILImageResampling.BILINEAR","`",")",":","Resampling","filter","to","use","when","resizing","the","image",".","data_format","(","`","ChannelDimension","`","or","`","str","`",",","*","optional","*",")",":","The","channel","dimension","format","for","the","output","image",".","If","unset",",","the","channel","dimension","format","of","the","input","image","is","used",".","input_data_format","(","`","ChannelDimension","`","or","`","str","`",",","*","optional","*",")",":","The","channel","dimension","format","of","the","input","image",".","If","not","provided",",","it","will","be","inferred","."]
code: def resize(
      self,
      image: np.ndarray,
      size: Dict[str, int],
      size_divisor: int = 0,
      resample: PILImageResampling = PILImageResampling.BILINEAR,
      data_format=None,
      input_data_format: Optional[Union[str, ChannelDimension]] = None,
      **kwargs,
  ) -> np.ndarray:
      """
      Resize the image to the given size. Size can be min_size (scalar) or `(height, width)` tuple. If size is an
      int, smaller edge of the image will be matched to this number.
  
      Args:
          image (`np.ndarray`):
              Image to resize.
          size (`Dict[str, int]`):
              The size of the output image.
          size_divisor (`int`, *optional*, defaults to 0):
              If `size_divisor` is given, the output image size will be divisible by the number.
          resample (`PILImageResampling` resampling filter, *optional*, defaults to `PILImageResampling.BILINEAR`):
              Resampling filter to use when resizing the image.
          data_format (`ChannelDimension` or `str`, *optional*):
              The channel dimension format for the output image. If unset, the channel dimension format of the input
              image is used.
          input_data_format (`ChannelDimension` or `str`, *optional*):
              The channel dimension format of the input image. If not provided, it will be inferred.
      """
      if "max_size" in kwargs:
          warnings.warn(
              "The `max_size` parameter is deprecated and will be removed in v4.27. "
              "Please specify in `size['longest_edge'] instead`.",
              FutureWarning,
          )
          max_size = kwargs.pop("max_size")
      else:
          max_size = None
      size = get_size_dict(
          size, max_size=max_size, default_to_square=False
      )
      if "shortest_edge" in size and "longest_edge" in size:
          size, max_size = size["shortest_edge"], size["longest_edge"]
      elif "height" in size and "width" in size:
          size = (size["height"], size["width"])
          max_size = None
      else:
          raise ValueError(
              "Size must contain 'height' and 'width' keys or 'shortest_edge' and 'longest_edge' keys. Got"
              f" {size.keys()}."
          )
      size = get_mask2former_resize_output_image_size(
          image=image,
          size=size,
          max_size=max_size,
          size_divisor=size_divisor,
          default_to_square=False,
          input_data_format=input_data_format,
      )
      image = resize(
          image,
          size=size,
          resample=resample,
          data_format=data_format,
          input_data_format=input_data_format,
          **kwargs,
      )
      return image
  
imports: import math
  import warnings
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Union
  import numpy
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import PaddingMode, get_resize_output_image_size, pad, rescale, resize, to_channel_dimension_format
  from ...image_utils import ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_batched, is_scaled_image, to_numpy_array, valid_images
  from ...utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, TensorType, is_torch_available, is_torch_tensor, logging
label_desc: Use image node_id 3 for calling the Mask2FormerImageProcessor obj's underlying member method code with example usage: obj.resize(image, size, size_divisor, resample, data_format, input_data_format) and returns: image