code: def resize(
      image,
      size: Tuple[int, int],
      resample=PILImageResampling.BILINEAR,
      data_format: Optional[ChannelDimension] = None,
      return_numpy: bool = True,
  ) -> np.ndarray:
      """
      Resizes `image` to (h, w) specified by `size` using the PIL library.
  
      Args:
          image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
              The image to resize.
          size (`Tuple[int, int]`):
              The size to use for resizing the image.
          resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BILINEAR`):
              The filter to user for resampling.
          data_format (`ChannelDimension`, *optional*):
              The channel dimension format of the output image. If `None`, 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.
  
      Returns:
          `np.ndarray`: The resized image.
      """
      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.
      data_format = (
          infer_channel_dimension_format(image)
          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
      if not isinstance(image, PIL.Image.Image):
          # PIL expects image to have channels last
          image = to_channel_dimension_format(
              image, ChannelDimension.LAST
          )
          image = to_pil_image(image)
      height, width = size
      # PIL images are in the format (width, height)
      resized_image = image.resize((width, height), resample=resample)
  
      if return_numpy:
          resized_image = np.array(resized_image)
          resized_image = to_channel_dimension_format(
              resized_image, data_format
          )
      return resized_image
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/image_transforms.py
imports: import warnings
  from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union
  import numpy
  from transformers.image_utils import PILImageResampling
  from transformers.utils.import_utils import is_flax_available, is_tf_available, is_torch_available, is_vision_available
label_desc: Use image node_id 5 for calling a global function with example usage: resize(image, size, resample, data_format, return_numpy) and returns: resized_image