class_docstr: Constructs a ViLT 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:
      do_resize (`bool`, *optional*, defaults to `True`):
          Whether to resize the input based on `size`.
      size (`int`, *optional*, defaults to 384):
          Resize the shorter side of the input to the given size. Should be an integer. The longer side will be
          limited to under int((1333 / 800) * size) while preserving the aspect ratio. Only has an effect if
          `do_resize` is set to `True`.
      size_divisor (`int`, *optional*, defaults to 32):
          The size by which to make sure both the height and width can be divided.
      resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BICUBIC`):
          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_normalize (`bool`, *optional*, defaults to `True`):
          Whether or not to normalize the input with mean and standard deviation.
      image_mean (`List[int]`, defaults to `[0.5, 0.5, 0.5]`):
          The sequence of means for each channel, to be used when normalizing images.
      image_std (`List[int]`, defaults to `[0.5, 0.5, 0.5]`):
          The sequence of standard deviations for each channel, to be used when normalizing images.
class_docstr_tok: ["Constructs","a","ViLT","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",":","do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","resize","the","input","based","on","`","size","`",".","size","(","`","int","`",",","*","optional","*",",","defaults","to","384",")",":","Resize","the","shorter","side","of","the","input","to","the","given","size",".","Should","be","an","integer",".","The","longer","side","will","be","limited","to","under","int","(","(","1333","\/","800",")","*","size",")","while","preserving","the","aspect","ratio",".","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","size_divisor","(","`","int","`",",","*","optional","*",",","defaults","to","32",")",":","The","size","by","which","to","make","sure","both","the","height","and","width","can","be","divided",".","resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","PIL.Image.Resampling.BICUBIC","`",")",":","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_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","normalize","the","input","with","mean","and","standard","deviation",".","image_mean","(","`","List","[","int","]","`",",","defaults","to","`","[","0.5",",","0.5",",","0.5","]","`",")",":","The","sequence","of","means","for","each","channel",",","to","be","used","when","normalizing","images",".","image_std","(","`","List","[","int","]","`",",","defaults","to","`","[","0.5",",","0.5",",","0.5","]","`",")",":","The","sequence","of","standard","deviations","for","each","channel",",","to","be","used","when","normalizing","images","."]
docstr: Resizes the shorter edge of `image` to `shorter` and limits the longer edge to under `longer`, while preserving
  the aspect ratio. Also makes sure that both the height and width can be divided by `size_divisor`.
  
  Based on original implementation:
  https://github.com/dandelin/ViLT/blob/3db8b5035464afee84d951bf6322e1b27f1d072d/vilt/transforms/utils.py#L5
  
  Args:
      image (`PIL.Image`):
          The image to resize.
      shorter (`int`, *optional*, defaults to `800`):
          The size to which to resize the shorter side of the image.
      longer (`int`, *optional*, defaults to `1333`):
          The size by which to limit the longer side of the image, while preserving the aspect ratio.
      size_divisor (`int`, *optional*, defaults to `32`):
          The size by which both the height and the width must be divisible.
      resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BICUBIC`):
          An optional resampling filter.
docstr_tok: ["Resizes","the","shorter","edge","of","`","image","`","to","`","shorter","`","and","limits","the","longer","edge","to","under","`","longer","`",",","while","preserving","the","aspect","ratio",".","Also","makes","sure","that","both","the","height","and","width","can","be","divided","by","`","size_divisor","`",".","Based","on","original","implementation",":","https",":","\/\/github.com\/dandelin\/ViLT\/blob\/3db8b5035464afee84d951bf6322e1b27f1d072d\/vilt\/transforms\/utils.py","#","L5","Args",":","image","(","`","PIL.Image","`",")",":","The","image","to","resize",".","shorter","(","`","int","`",",","*","optional","*",",","defaults","to","`","800","`",")",":","The","size","to","which","to","resize","the","shorter","side","of","the","image",".","longer","(","`","int","`",",","*","optional","*",",","defaults","to","`","1333","`",")",":","The","size","by","which","to","limit","the","longer","side","of","the","image",",","while","preserving","the","aspect","ratio",".","size_divisor","(","`","int","`",",","*","optional","*",",","defaults","to","`","32","`",")",":","The","size","by","which","both","the","height","and","the","width","must","be","divisible",".","resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","PIL.Image.Resampling.BICUBIC","`",")",":","An","optional","resampling","filter","."]
code: def _resize(
      self,
      image,
      shorter=800,
      longer=1333,
      size_divisor=32,
      resample=PILImageResampling.BICUBIC,
  ):
      """
      Resizes the shorter edge of `image` to `shorter` and limits the longer edge to under `longer`, while preserving
      the aspect ratio. Also makes sure that both the height and width can be divided by `size_divisor`.
  
      Based on original implementation:
      https://github.com/dandelin/ViLT/blob/3db8b5035464afee84d951bf6322e1b27f1d072d/vilt/transforms/utils.py#L5
  
      Args:
          image (`PIL.Image`):
              The image to resize.
          shorter (`int`, *optional*, defaults to `800`):
              The size to which to resize the shorter side of the image.
          longer (`int`, *optional*, defaults to `1333`):
              The size by which to limit the longer side of the image, while preserving the aspect ratio.
          size_divisor (`int`, *optional*, defaults to `32`):
              The size by which both the height and the width must be divisible.
          resample (`int`, *optional*, defaults to `PIL.Image.Resampling.BICUBIC`):
              An optional resampling filter.
      """
      if not isinstance(image, Image.Image):
          image = self.to_pil_image(image)
  
      w, h = image.size
      min_size = shorter
      max_size = longer
      scale = min_size / min(w, h)
      if h < w:
          newh, neww = min_size, scale * w
      else:
          newh, neww = scale * h, min_size
  
      if max(newh, neww) > max_size:
          scale = max_size / max(newh, neww)
          newh = newh * scale
          neww = neww * scale
  
      newh, neww = int(newh + 0.5), int(neww + 0.5)
      newh, neww = (
          newh // size_divisor * size_divisor,
          neww // size_divisor * size_divisor,
      )
  
      return self.resize(image, size=(neww, newh), resample=resample)
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/vilt/feature_extraction_vilt.py
imports: from typing import List, Optional, Union
  import numpy
  from PIL import Image
  from transformers.image_utils import PILImageResampling
  from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin
  from ...image_utils import IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD, ImageFeatureExtractionMixin, ImageInput, is_torch_tensor
  from ...utils import TensorType, is_torch_available, logging
label_desc: Use image node_id 2 for calling the ViltFeatureExtractor obj's underlying member method code with example usage: obj._resize(image, shorter, longer, size_divisor, resample) and returns: self