class_docstr: Constructs a Perceiver feature extractor.
  
  This feature extractor inherits from [`ImageFeatureExtractionMixin`] which contains most of the main methods. Users
  should refer to this superclass for more information regarding those methods.
  
  Args:
      do_center_crop (`bool`, *optional*, defaults to `True`):
          Whether to crop the input at the center. If the input size is smaller than `crop_size` along any edge, the
          image is padded with 0's and then center cropped.
      crop_size (`int`, *optional*, defaults to 256):
          Desired output size when applying center-cropping. Only has an effect if `do_center_crop` is set to `True`.
      do_resize (`bool`, *optional*, defaults to `True`):
          Whether to resize the input to a certain `size`.
      size (`int` or `Tuple(int)`, *optional*, defaults to 224):
          Resize the input to the given size. If a tuple is provided, it should be (width, height). If only an
          integer is provided, then the input will be resized to (size, size). Only has an effect if `do_resize` is
          set to `True`.
      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 `image_mean` and `image_std`.
      image_mean (`List[int]`, defaults to `[0.485, 0.456, 0.406]`):
          The sequence of means for each channel, to be used when normalizing images.
      image_std (`List[int]`, defaults to `[0.229, 0.224, 0.225]`):
          The sequence of standard deviations for each channel, to be used when normalizing images.
class_docstr_tok: ["Constructs","a","Perceiver","feature","extractor",".","This","feature","extractor","inherits","from","[","`","ImageFeatureExtractionMixin","`","]","which","contains","most","of","the","main","methods",".","Users","should","refer","to","this","superclass","for","more","information","regarding","those","methods",".","Args",":","do_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","crop","the","input","at","the","center",".","If","the","input","size","is","smaller","than","`","crop_size","`","along","any","edge",",","the","image","is","padded","with","0","'s","and","then","center","cropped",".","crop_size","(","`","int","`",",","*","optional","*",",","defaults","to","256",")",":","Desired","output","size","when","applying","center-cropping",".","Only","has","an","effect","if","`","do_center_crop","`","is","set","to","`","True","`",".","do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","resize","the","input","to","a","certain","`","size","`",".","size","(","`","int","`","or","`","Tuple","(","int",")","`",",","*","optional","*",",","defaults","to","224",")",":","Resize","the","input","to","the","given","size",".","If","a","tuple","is","provided",",","it","should","be","(","width",",","height",")",".","If","only","an","integer","is","provided",",","then","the","input","will","be","resized","to","(","size",",","size",")",".","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","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","`","image_mean","`","and","`","image_std","`",".","image_mean","(","`","List","[","int","]","`",",","defaults","to","`","[","0.485",",","0.456",",","0.406","]","`",")",":","The","sequence","of","means","for","each","channel",",","to","be","used","when","normalizing","images",".","image_std","(","`","List","[","int","]","`",",","defaults","to","`","[","0.229",",","0.224",",","0.225","]","`",")",":","The","sequence","of","standard","deviations","for","each","channel",",","to","be","used","when","normalizing","images","."]
docstr: Crops `image` to *self.crop_size* using a center crop. Note that if the image is too small to be cropped to the
  size given, it will be padded (so the returned result has the size asked).
  
  Args:
      image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
          The image to resize.
docstr_tok: ["Crops","`","image","`","to","*","self.crop_size","*","using","a","center","crop",".","Note","that","if","the","image","is","too","small","to","be","cropped","to","the","size","given",",","it","will","be","padded","(","so","the","returned","result","has","the","size","asked",")",".","Args",":","image","(","`","PIL.Image.Image","`","or","`","np.ndarray","`","or","`","torch.Tensor","`",")",":","The","image","to","resize","."]
code: def center_crop(self, image):
      """
      Crops `image` to *self.crop_size* using a center crop. Note that if the image is too small to be cropped to the
      size given, it will be padded (so the returned result has the size asked).
  
      Args:
          image (`PIL.Image.Image` or `np.ndarray` or `torch.Tensor`):
              The image to resize.
      """
  
      if isinstance(image, Image.Image):
          image = self.to_numpy_array(image)
  
      image_height, image_width = image.shape[-2:]
  
      padded_center_crop_size = (
          (self.size / (self.crop_size))
          * np.minimum(image_height, image_width).astype(np.float32)
      ).astype(np.int32)
  
      offset_height = (
          (image_height - padded_center_crop_size) + 1
      ) // 2
      offset_width = ((image_width - padded_center_crop_size) + 1) // 2
      crop_window = [
          offset_height,
          offset_width,
          padded_center_crop_size,
          padded_center_crop_size,
      ]
  
      image = image[
          :,
          crop_window[0] : crop_window[0] + crop_window[2],
          crop_window[1] : crop_window[1] + crop_window[3],
      ]
  
      return image
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/perceiver/feature_extraction_perceiver.py
imports: from typing import 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_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, ImageFeatureExtractionMixin, ImageInput, is_torch_tensor
  from ...utils import TensorType, logging
label_desc: Use image node_id 2 for calling the PerceiverFeatureExtractor obj's underlying member method code with example usage: obj.center_crop(image) and returns: image