class_docstr: Constructs a VideoMAE feature extractor. This feature extractor can be used to prepare videos for the model.
  
  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 shorter edge of the input to a certain `size`.
      size (`int`, *optional*, defaults to 224):
          Resize the shorter edge of the input to the given size. Only has an effect if `do_resize` is set to `True`.
      resample (`int`, *optional*, defaults to `PIL.Image.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_center_crop (`bool`, *optional*, defaults to `True`):
          Whether to center crop the input to a certain `size`.
      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.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","VideoMAE","feature","extractor",".","This","feature","extractor","can","be","used","to","prepare","videos","for","the","model",".","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","shorter","edge","of","the","input","to","a","certain","`","size","`",".","size","(","`","int","`",",","*","optional","*",",","defaults","to","224",")",":","Resize","the","shorter","edge","of","the","input","to","the","given","size",".","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","PIL.Image.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_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","center","crop","the","input","to","a","certain","`","size","`",".","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.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: Main method to prepare for the model one or several video(s).
  
  <Tip warning={true}>
  
  NumPy arrays are converted to PIL images when resizing, so the most efficient is to pass PIL images.
  
  </Tip>
  
  Args:
      videos (`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`, `List[List[PIL.Image.Image]]`, `List[List[np.ndarrray]]`,:
          `List[List[torch.Tensor]]`): The video or batch of videos to be prepared. Each video should be a list
          of frames, which can be either PIL images or NumPy arrays. In case of NumPy arrays/PyTorch tensors,
          each frame should be of shape (H, W, C), where H and W are frame height and width, and C is a number of
          channels.
  
      return_tensors (`str` or [`~utils.TensorType`], *optional*, defaults to `'np'`):
          If set, will return tensors of a particular framework. Acceptable values are:
  
          - `'tf'`: Return TensorFlow `tf.constant` objects.
          - `'pt'`: Return PyTorch `torch.Tensor` objects.
          - `'np'`: Return NumPy `np.ndarray` objects.
          - `'jax'`: Return JAX `jnp.ndarray` objects.
  
  Returns:
      [`BatchFeature`]: A [`BatchFeature`] with the following fields:
  
      - **pixel_values** -- Pixel values to be fed to a model, of shape (batch_size, num_channels, num_frames,
        height, width).
docstr_tok: ["Main","method","to","prepare","for","the","model","one","or","several","video","(","s",")",".","<","Tip","warning=","{","true","}",">","NumPy","arrays","are","converted","to","PIL","images","when","resizing",",","so","the","most","efficient","is","to","pass","PIL","images",".","<","\/Tip",">","Args",":","videos","(","`","List","[","PIL.Image.Image","]","`",",","`","List","[","np.ndarray","]","`",",","`","List","[","torch.Tensor","]","`",",","`","List","[","List","[","PIL.Image.Image","]","]","`",",","`","List","[","List","[","np.ndarrray","]","]","`",",",":","`","List","[","List","[","torch.Tensor","]","]","`",")",":","The","video","or","batch","of","videos","to","be","prepared",".","Each","video","should","be","a","list","of","frames",",","which","can","be","either","PIL","images","or","NumPy","arrays",".","In","case","of","NumPy","arrays\/PyTorch","tensors",",","each","frame","should","be","of","shape","(","H",",","W",",","C",")",",","where","H","and","W","are","frame","height","and","width",",","and","C","is","a","number","of","channels",".","return_tensors","(","`","str","`","or","[","`","~utils.TensorType","`","]",",","*","optional","*",",","defaults","to","`","'np","'","`",")",":","If","set",",","will","return","tensors","of","a","particular","framework",".","Acceptable","values","are",":","-","`","'tf","'","`",":","Return","TensorFlow","`","tf.constant","`","objects",".","-","`","'pt","'","`",":","Return","PyTorch","`","torch.Tensor","`","objects",".","-","`","'np","'","`",":","Return","NumPy","`","np.ndarray","`","objects",".","-","`","'jax","'","`",":","Return","JAX","`","jnp.ndarray","`","objects",".","Returns",":","[","`","BatchFeature","`","]",":","A","[","`","BatchFeature","`","]","with","the","following","fields",":","-","*","*","pixel_values","*","*","--","Pixel","values","to","be","fed","to","a","model",",","of","shape","(","batch_size",",","num_channels",",","num_frames",",","height",",","width",")","."]
code: def __call__(
      self,
      videos: ImageInput,
      return_tensors: Optional[Union[str, TensorType]] = None,
      **kwargs,
  ) -> BatchFeature:
      """
      Main method to prepare for the model one or several video(s).
  
      <Tip warning={true}>
  
      NumPy arrays are converted to PIL images when resizing, so the most efficient is to pass PIL images.
  
      </Tip>
  
      Args:
          videos (`List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]`, `List[List[PIL.Image.Image]]`, `List[List[np.ndarrray]]`,:
              `List[List[torch.Tensor]]`): The video or batch of videos to be prepared. Each video should be a list
              of frames, which can be either PIL images or NumPy arrays. In case of NumPy arrays/PyTorch tensors,
              each frame should be of shape (H, W, C), where H and W are frame height and width, and C is a number of
              channels.
  
          return_tensors (`str` or [`~utils.TensorType`], *optional*, defaults to `'np'`):
              If set, will return tensors of a particular framework. Acceptable values are:
  
              - `'tf'`: Return TensorFlow `tf.constant` objects.
              - `'pt'`: Return PyTorch `torch.Tensor` objects.
              - `'np'`: Return NumPy `np.ndarray` objects.
              - `'jax'`: Return JAX `jnp.ndarray` objects.
  
      Returns:
          [`BatchFeature`]: A [`BatchFeature`] with the following fields:
  
          - **pixel_values** -- Pixel values to be fed to a model, of shape (batch_size, num_channels, num_frames,
            height, width).
      """
      # Input type checking for clearer error
      valid_videos = False
      is_batched = False
  
      # Check that videos have a valid type
      if isinstance(videos, (list, tuple)):
          if isinstance(
              videos[0], (Image.Image, np.ndarray)
          ) or is_torch_tensor(videos[0]):
              valid_videos = True
          elif isinstance(videos[0], (list, tuple)) and (
              isinstance(videos[0][0], (Image.Image, np.ndarray))
              or is_torch_tensor(videos[0][0])
          ):
              valid_videos = True
              is_batched = True
  
      if not valid_videos:
          raise ValueError(
              "Videos must of type `List[PIL.Image.Image]`, `List[np.ndarray]`, `List[torch.Tensor]` (single"
              " example), `List[List[PIL.Image.Image]]`, `List[List[np.ndarray]]`, `List[List[torch.Tensor]]` (batch"
              " of examples)."
          )
  
      if not is_batched:
          videos = [videos]
  
      # transformations (resizing + center cropping + normalization)
      if self.do_resize and self.size is not None:
          videos = [
              self.resize_video(
                  video, size=self.size, resample=self.resample
              )
              for video in videos
          ]
      if self.do_center_crop and self.size is not None:
          videos = [
              self.crop_video(video, size=self.size) for video in videos
          ]
      if self.do_normalize:
          videos = [
              self.normalize_video(
                  video, mean=self.image_mean, std=self.image_std
              )
              for video in videos
          ]
  
      # return as BatchFeature
      data = {"pixel_values": videos}
      encoded_inputs = BatchFeature(
          data=data, tensor_type=return_tensors
      )
  
      return encoded_inputs
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/models/videomae/feature_extraction_videomae.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 ImageFeatureExtractionMixin, ImageInput, is_torch_tensor
  from ...utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, TensorType, logging
label_desc: Use image node_id 5 for calling the VideoMAEFeatureExtractor obj's underlying member method code with example usage: obj.__call__(videos, return_tensors) and returns: encoded_inputs