code: def resize(
      image: np.ndarray,
      size: Tuple[int, int],
      resample: "PILImageResampling" = None,
      reducing_gap: Optional[int] = None,
      data_format: Optional[ChannelDimension] = None,
      return_numpy: bool = True,
      input_data_format: Optional[Union[str, ChannelDimension]] = None,
  ) -> np.ndarray:
      """
      Resizes `image` to `(height, width)` specified by `size` using the PIL library.
  
      Args:
          image (`np.ndarray`):
              The image to resize.
          size (`Tuple[int, int]`):
              The size to use for resizing the image.
          resample (`int`, *optional*, defaults to `PILImageResampling.BILINEAR`):
              The filter to user for resampling.
          reducing_gap (`int`, *optional*):
              Apply optimization by resizing the image in two steps. The bigger `reducing_gap`, the closer the result to
              the fair resampling. See corresponding Pillow documentation for more details.
          data_format (`ChannelDimension`, *optional*):
              The channel dimension format of the output image. If unset, will use the inferred format from the input.
          return_numpy (`bool`, *optional*, defaults to `True`):
              Whether or not to return the resized image as a numpy array. If False a `PIL.Image.Image` object is
              returned.
          input_data_format (`ChannelDimension`, *optional*):
              The channel dimension format of the input image. If unset, will use the inferred format from the input.
  
      Returns:
          `np.ndarray`: The resized image.
      """
      requires_backends(resize, ["vision"])
  
      resample = (
          resample
          if resample is not None
          else PILImageResampling.BILINEAR
      )
  
      if not len(size) == 2:
          raise ValueError("size must have 2 elements")
  
      # For all transformations, we want to keep the same data format as the input image unless otherwise specified.
      # The resized image from PIL will always have channels last, so find the input format first.
      if input_data_format is None:
          input_data_format = infer_channel_dimension_format(image)
      data_format = (
          input_data_format if data_format is None else data_format
      )
  
      # To maintain backwards compatibility with the resizing done in previous image feature extractors, we use
      # the pillow library to resize the image and then convert back to numpy
      do_rescale = False
      if not isinstance(image, PIL.Image.Image):
          do_rescale = _rescale_for_pil_conversion(image)
          image = to_pil_image(
              image,
              do_rescale=do_rescale,
              input_data_format=input_data_format,
          )
      height, width = size
      # PIL images are in the format (width, height)
      resized_image = image.resize(
          (width, height), resample=resample, reducing_gap=reducing_gap
      )
  
      if return_numpy:
          resized_image = np.array(resized_image)
          # If the input image channel dimension was of size 1, then it is dropped when converting to a PIL image
          # so we need to add it back if necessary.
          resized_image = (
              np.expand_dims(resized_image, axis=-1)
              if resized_image.ndim == 2
              else resized_image
          )
          # The image is always in channels last format after converting from a PIL image
          resized_image = to_channel_dimension_format(
              resized_image,
              data_format,
              input_channel_dim=ChannelDimension.LAST,
          )
          # If an image was rescaled to be in the range [0, 255] before converting to a PIL image, then we need to
          # rescale it back to the original range.
          resized_image = (
              rescale(resized_image, 1 / 255)
              if do_rescale
              else resized_image
          )
      return resized_image
  
imports: import warnings
  from typing import Iterable, List, Optional, Tuple, Union
  import numpy
  from .image_utils import ChannelDimension, ImageInput, get_channel_dimension_axis, get_image_size, infer_channel_dimension_format
  from .utils import ExplicitEnum, TensorType, is_jax_tensor, is_tf_tensor, is_torch_tensor
  from .utils.import_utils import is_flax_available, is_tf_available, is_torch_available, is_vision_available, requires_backends
label_desc: Use image node_id 6 for calling a global function with example usage: resize(image, size, resample, reducing_gap, data_format, return_numpy, input_data_format) and returns: resized_image