class_docstr: Constructs a Flava image processor.
  
  Args:
      do_resize (`bool`, *optional*, defaults to `True`):
          Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by the
          `do_resize` parameter in `preprocess`.
      size (`Dict[str, int]` *optional*, defaults to `{"height": 224, "width": 224}`):
          Size of the image after resizing. Can be overridden by the `size` parameter in `preprocess`.
      resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.BICUBIC`):
          Resampling filter to use if resizing the image. Can be overridden by the `resample` parameter in
          `preprocess`.
      do_center_crop (`bool`, *optional*, defaults to `True`):
          Whether to center crop the images. Can be overridden by the `do_center_crop` parameter in `preprocess`.
      crop_size (`Dict[str, int]` *optional*, defaults to `{"height": 224, "width": 224}`):
          Size of image after the center crop `(crop_size["height"], crop_size["width"])`. Can be overridden by the
          `crop_size` parameter in `preprocess`.
      do_rescale (`bool`, *optional*, defaults to `True`):
          Whether to rescale the image by the specified scale `rescale_factor`. Can be overridden by the `do_rescale`
          parameter in `preprocess`.
      rescale_factor (`int` or `float`, *optional*, defaults to `1/255`):
          Scale factor to use if rescaling the image. Can be overridden by the `rescale_factor` parameter in
          `preprocess`.
      do_normalize (`bool`, *optional*, defaults to `True`):
          Whether to normalize the image. Can be overridden by the `do_normalize` parameter in `preprocess`.
      image_mean (`float` or `List[float]`, *optional*, defaults to `IMAGENET_STANDARD_MEAN`):
          Mean to use if normalizing the image. This is a float or list of floats the length of the number of
          channels in the image. Can be overridden by the `image_mean` parameter in the `preprocess` method.
      image_std (`float` or `List[float]`, *optional*, defaults to `IMAGENET_STANDARD_STD`):
          Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
          number of channels in the image. Can be overridden by the `image_std` parameter in the `preprocess` method.
      return_image_mask (`bool`, *optional*, defaults to `False`):
          Whether to return the image mask. Can be overridden by the `return_image_mask` parameter in `preprocess`.
      input_size_patches (`int`, *optional*, defaults to 14):
          Number of patches in the image in height and width direction. 14x14 = 196 total patches. Can be overridden
          by the `input_size_patches` parameter in `preprocess`.
      total_mask_patches (`int`, *optional*, defaults to 75):
          Total number of patches that should be masked. Can be overridden by the `total_mask_patches` parameter in
          `preprocess`.
      mask_group_min_patches (`int`, *optional*, defaults to 16):
          Minimum number of patches that should be masked. Can be overridden by the `mask_group_min_patches`
          parameter in `preprocess`.
      mask_group_max_patches (`int`, *optional*):
          Maximum number of patches that should be masked. Can be overridden by the `mask_group_max_patches`
          parameter in `preprocess`.
      mask_group_min_aspect_ratio (`float`, *optional*, defaults to 0.3):
          Minimum aspect ratio of the mask window. Can be overridden by the `mask_group_min_aspect_ratio` parameter
          in `preprocess`.
      mask_group_max_aspect_ratio (`float`, *optional*):
          Maximum aspect ratio of the mask window. Can be overridden by the `mask_group_max_aspect_ratio` parameter
          in `preprocess`.
      codebook_do_resize (`bool`, *optional*, defaults to `True`):
          Whether to resize the input for codebook to a certain. Can be overridden by the `codebook_do_resize`
          parameter in `preprocess`. `codebook_size`.
      codebook_size (`Dict[str, int]`, *optional*, defaults to `{"height": 224, "width": 224}`):
          Resize the input for codebook to the given size. Can be overridden by the `codebook_size` parameter in
          `preprocess`.
      codebook_resample (`PILImageResampling`, *optional*, defaults to `PILImageResampling.LANCZOS`):
          Resampling filter to use if resizing the codebook image. Can be overridden by the `codebook_resample`
          parameter in `preprocess`.
      codebook_do_center_crop (`bool`, *optional*, defaults to `True`):
          Whether to crop the input for codebook at the center. If the input size is smaller than
          `codebook_crop_size` along any edge, the image is padded with 0's and then center cropped. Can be
          overridden by the `codebook_do_center_crop` parameter in `preprocess`.
      codebook_crop_size (`Dict[str, int]`, *optional*, defaults to `{"height": 224, "width": 224}`):
          Desired output size for codebook input when applying center-cropping. Can be overridden by the
          `codebook_crop_size` parameter in `preprocess`.
      codebook_do_rescale (`bool`, *optional*, defaults to `True`):
          Whether to rescale the input for codebook by the specified scale `codebook_rescale_factor`. Can be
          overridden by the `codebook_do_rescale` parameter in `preprocess`.
      codebook_rescale_factor (`int` or `float`, *optional*, defaults to `1/255`):
          Defines the scale factor to use if rescaling the codebook image. Can be overridden by the
          `codebook_rescale_factor` parameter in `preprocess`.
      codebook_do_map_pixels (`bool`, *optional*, defaults to `True`):
          Whether to map the pixel values of the codebook input to (1 - 2e)x + e. Can be overridden by the
          `codebook_do_map_pixels` parameter in `preprocess`.
      codebook_do_normalize (`bool`, *optional*, defaults to `True`):
          Whether or not to normalize the input for codebook with `codebook_image_mean` and `codebook_image_std`. Can
          be overridden by the `codebook_do_normalize` parameter in `preprocess`.
      codebook_image_mean (`Optional[Union[float, Iterable[float]]]`, *optional*, defaults to `[0, 0, 0]`):
          The sequence of means for each channel, to be used when normalizing images for codebook. Can be overridden
          by the `codebook_image_mean` parameter in `preprocess`.
      codebook_image_std (`Optional[Union[float, Iterable[float]]]`, *optional*, defaults to `[0.5, 0.5, 0.5]`):
          The sequence of standard deviations for each channel, to be used when normalizing images for codebook. Can
          be overridden by the `codebook_image_std` parameter in `preprocess`.
class_docstr_tok: ["Constructs","a","Flava","image","processor",".","Args",":","do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","resize","the","image","'s","(","height",",","width",")","dimensions","to","the","specified","`","size","`",".","Can","be","overridden","by","the","`","do_resize","`","parameter","in","`","preprocess","`",".","size","(","`","Dict","[","str",",","int","]","`","*","optional","*",",","defaults","to","`","{","``","height","''",":","224",",","``","width","''",":","224","}","`",")",":","Size","of","the","image","after","resizing",".","Can","be","overridden","by","the","`","size","`","parameter","in","`","preprocess","`",".","resample","(","`","PILImageResampling","`",",","*","optional","*",",","defaults","to","`","PILImageResampling.BICUBIC","`",")",":","Resampling","filter","to","use","if","resizing","the","image",".","Can","be","overridden","by","the","`","resample","`","parameter","in","`","preprocess","`",".","do_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","center","crop","the","images",".","Can","be","overridden","by","the","`","do_center_crop","`","parameter","in","`","preprocess","`",".","crop_size","(","`","Dict","[","str",",","int","]","`","*","optional","*",",","defaults","to","`","{","``","height","''",":","224",",","``","width","''",":","224","}","`",")",":","Size","of","image","after","the","center","crop","`","(","crop_size","[","``","height","''","]",",","crop_size","[","``","width","''","]",")","`",".","Can","be","overridden","by","the","`","crop_size","`","parameter","in","`","preprocess","`",".","do_rescale","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","rescale","the","image","by","the","specified","scale","`","rescale_factor","`",".","Can","be","overridden","by","the","`","do_rescale","`","parameter","in","`","preprocess","`",".","rescale_factor","(","`","int","`","or","`","float","`",",","*","optional","*",",","defaults","to","`","1\/255","`",")",":","Scale","factor","to","use","if","rescaling","the","image",".","Can","be","overridden","by","the","`","rescale_factor","`","parameter","in","`","preprocess","`",".","do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","normalize","the","image",".","Can","be","overridden","by","the","`","do_normalize","`","parameter","in","`","preprocess","`",".","image_mean","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","IMAGENET_STANDARD_MEAN","`",")",":","Mean","to","use","if","normalizing","the","image",".","This","is","a","float","or","list","of","floats","the","length","of","the","number","of","channels","in","the","image",".","Can","be","overridden","by","the","`","image_mean","`","parameter","in","the","`","preprocess","`","method",".","image_std","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","IMAGENET_STANDARD_STD","`",")",":","Standard","deviation","to","use","if","normalizing","the","image",".","This","is","a","float","or","list","of","floats","the","length","of","the","number","of","channels","in","the","image",".","Can","be","overridden","by","the","`","image_std","`","parameter","in","the","`","preprocess","`","method",".","return_image_mask","(","`","bool","`",",","*","optional","*",",","defaults","to","`","False","`",")",":","Whether","to","return","the","image","mask",".","Can","be","overridden","by","the","`","return_image_mask","`","parameter","in","`","preprocess","`",".","input_size_patches","(","`","int","`",",","*","optional","*",",","defaults","to","14",")",":","Number","of","patches","in","the","image","in","height","and","width","direction",".","14x14","=","196","total","patches",".","Can","be","overridden","by","the","`","input_size_patches","`","parameter","in","`","preprocess","`",".","total_mask_patches","(","`","int","`",",","*","optional","*",",","defaults","to","75",")",":","Total","number","of","patches","that","should","be","masked",".","Can","be","overridden","by","the","`","total_mask_patches","`","parameter","in","`","preprocess","`",".","mask_group_min_patches","(","`","int","`",",","*","optional","*",",","defaults","to","16",")",":","Minimum","number","of","patches","that","should","be","masked",".","Can","be","overridden","by","the","`","mask_group_min_patches","`","parameter","in","`","preprocess","`",".","mask_group_max_patches","(","`","int","`",",","*","optional","*",")",":","Maximum","number","of","patches","that","should","be","masked",".","Can","be","overridden","by","the","`","mask_group_max_patches","`","parameter","in","`","preprocess","`",".","mask_group_min_aspect_ratio","(","`","float","`",",","*","optional","*",",","defaults","to","0.3",")",":","Minimum","aspect","ratio","of","the","mask","window",".","Can","be","overridden","by","the","`","mask_group_min_aspect_ratio","`","parameter","in","`","preprocess","`",".","mask_group_max_aspect_ratio","(","`","float","`",",","*","optional","*",")",":","Maximum","aspect","ratio","of","the","mask","window",".","Can","be","overridden","by","the","`","mask_group_max_aspect_ratio","`","parameter","in","`","preprocess","`",".","codebook_do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","resize","the","input","for","codebook","to","a","certain",".","Can","be","overridden","by","the","`","codebook_do_resize","`","parameter","in","`","preprocess","`",".","`","codebook_size","`",".","codebook_size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","{","``","height","''",":","224",",","``","width","''",":","224","}","`",")",":","Resize","the","input","for","codebook","to","the","given","size",".","Can","be","overridden","by","the","`","codebook_size","`","parameter","in","`","preprocess","`",".","codebook_resample","(","`","PILImageResampling","`",",","*","optional","*",",","defaults","to","`","PILImageResampling.LANCZOS","`",")",":","Resampling","filter","to","use","if","resizing","the","codebook","image",".","Can","be","overridden","by","the","`","codebook_resample","`","parameter","in","`","preprocess","`",".","codebook_do_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","crop","the","input","for","codebook","at","the","center",".","If","the","input","size","is","smaller","than","`","codebook_crop_size","`","along","any","edge",",","the","image","is","padded","with","0","'s","and","then","center","cropped",".","Can","be","overridden","by","the","`","codebook_do_center_crop","`","parameter","in","`","preprocess","`",".","codebook_crop_size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","{","``","height","''",":","224",",","``","width","''",":","224","}","`",")",":","Desired","output","size","for","codebook","input","when","applying","center-cropping",".","Can","be","overridden","by","the","`","codebook_crop_size","`","parameter","in","`","preprocess","`",".","codebook_do_rescale","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","rescale","the","input","for","codebook","by","the","specified","scale","`","codebook_rescale_factor","`",".","Can","be","overridden","by","the","`","codebook_do_rescale","`","parameter","in","`","preprocess","`",".","codebook_rescale_factor","(","`","int","`","or","`","float","`",",","*","optional","*",",","defaults","to","`","1\/255","`",")",":","Defines","the","scale","factor","to","use","if","rescaling","the","codebook","image",".","Can","be","overridden","by","the","`","codebook_rescale_factor","`","parameter","in","`","preprocess","`",".","codebook_do_map_pixels","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","to","map","the","pixel","values","of","the","codebook","input","to","(","1","-","2e",")","x","+","e.","Can","be","overridden","by","the","`","codebook_do_map_pixels","`","parameter","in","`","preprocess","`",".","codebook_do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","True","`",")",":","Whether","or","not","to","normalize","the","input","for","codebook","with","`","codebook_image_mean","`","and","`","codebook_image_std","`",".","Can","be","overridden","by","the","`","codebook_do_normalize","`","parameter","in","`","preprocess","`",".","codebook_image_mean","(","`","Optional","[","Union","[","float",",","Iterable","[","float","]","]","]","`",",","*","optional","*",",","defaults","to","`","[","0",",","0",",","0","]","`",")",":","The","sequence","of","means","for","each","channel",",","to","be","used","when","normalizing","images","for","codebook",".","Can","be","overridden","by","the","`","codebook_image_mean","`","parameter","in","`","preprocess","`",".","codebook_image_std","(","`","Optional","[","Union","[","float",",","Iterable","[","float","]","]","]","`",",","*","optional","*",",","defaults","to","`","[","0.5",",","0.5",",","0.5","]","`",")",":","The","sequence","of","standard","deviations","for","each","channel",",","to","be","used","when","normalizing","images","for","codebook",".","Can","be","overridden","by","the","`","codebook_image_std","`","parameter","in","`","preprocess","`","."]
docstr: Preprocess an image or batch of images.
  
  Args:
      images (`ImageInput`):
          Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
          passing in images with pixel values between 0 and 1, set `do_rescale=False`.
      do_resize (`bool`, *optional*, defaults to `self.do_resize`):
          Whether to resize the image.
      size (`Dict[str, int]`, *optional*, defaults to `self.size`):
          Size of the image.
      resample (`int`, *optional*, defaults to `self.resample`):
          Resampling filter to use if resizing the image. This can be one of the enum `PILImageResampling`, Only
          has an effect if `do_resize` is set to `True`.
      do_center_crop (`bool`, *optional*, defaults to `self.do_center_crop`):
          Whether to center crop the image.
      crop_size (`Dict[str, int]`, *optional*, defaults to `self.crop_size`):
          Size of the center crop. Only has an effect if `do_center_crop` is set to `True`.
      do_rescale (`bool`, *optional*, defaults to `self.do_rescale`):
          Whether to rescale the image values between [0 - 1].
      rescale_factor (`float`, *optional*, defaults to `self.rescale_factor`):
          Rescale factor to rescale the image by if `do_rescale` is set to `True`.
      do_normalize (`bool`, *optional*, defaults to `self.do_normalize`):
          Whether to normalize the image.
      image_mean (`float` or `List[float]`, *optional*, defaults to `self.image_mean`):
          Image mean.
      image_std (`float` or `List[float]`, *optional*, defaults to `self.image_std`):
          Image standard deviation.
      return_image_mask (`bool`, *optional*, defaults to `self.return_image_mask`):
          Whether to return the image mask.
      input_size_patches (`int`, *optional*, defaults to `self.input_size_patches`):
          Size of the patches to extract from the image.
      total_mask_patches (`int`, *optional*, defaults to `self.total_mask_patches`):
          Total number of patches to extract from the image.
      mask_group_min_patches (`int`, *optional*, defaults to `self.mask_group_min_patches`):
          Minimum number of patches to extract from the image.
      mask_group_max_patches (`int`, *optional*, defaults to `self.mask_group_max_patches`):
          Maximum number of patches to extract from the image.
      mask_group_min_aspect_ratio (`float`, *optional*, defaults to `self.mask_group_min_aspect_ratio`):
          Minimum aspect ratio of the patches to extract from the image.
      mask_group_max_aspect_ratio (`float`, *optional*, defaults to `self.mask_group_max_aspect_ratio`):
          Maximum aspect ratio of the patches to extract from the image.
      return_codebook_pixels (`bool`, *optional*, defaults to `self.return_codebook_pixels`):
          Whether to return the codebook pixels.
      codebook_do_resize (`bool`, *optional*, defaults to `self.codebook_do_resize`):
          Whether to resize the codebook pixels.
      codebook_size (`Dict[str, int]`, *optional*, defaults to `self.codebook_size`):
          Size of the codebook pixels.
      codebook_resample (`int`, *optional*, defaults to `self.codebook_resample`):
          Resampling filter to use if resizing the codebook pixels. This can be one of the enum
          `PILImageResampling`, Only has an effect if `codebook_do_resize` is set to `True`.
      codebook_do_center_crop (`bool`, *optional*, defaults to `self.codebook_do_center_crop`):
          Whether to center crop the codebook pixels.
      codebook_crop_size (`Dict[str, int]`, *optional*, defaults to `self.codebook_crop_size`):
          Size of the center crop of the codebook pixels. Only has an effect if `codebook_do_center_crop` is set
          to `True`.
      codebook_do_rescale (`bool`, *optional*, defaults to `self.codebook_do_rescale`):
          Whether to rescale the codebook pixels values between [0 - 1].
      codebook_rescale_factor (`float`, *optional*, defaults to `self.codebook_rescale_factor`):
          Rescale factor to rescale the codebook pixels by if `codebook_do_rescale` is set to `True`.
      codebook_do_map_pixels (`bool`, *optional*, defaults to `self.codebook_do_map_pixels`):
          Whether to map the codebook pixels values.
      codebook_do_normalize (`bool`, *optional*, defaults to `self.codebook_do_normalize`):
          Whether to normalize the codebook pixels.
      codebook_image_mean (`float` or `List[float]`, *optional*, defaults to `self.codebook_image_mean`):
          Codebook pixels mean to normalize the codebook pixels by if `codebook_do_normalize` is set to `True`.
      codebook_image_std (`float` or `List[float]`, *optional*, defaults to `self.codebook_image_std`):
          Codebook pixels standard deviation to normalize the codebook pixels by if `codebook_do_normalize` is
          set to `True`.
      return_tensors (`str` or `TensorType`, *optional*):
          The type of tensors to return. Can be one of:
              - Unset: Return a list of `np.ndarray`.
              - `TensorType.TENSORFLOW` or `'tf'`: Return a batch of type `tf.Tensor`.
              - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
              - `TensorType.NUMPY` or `'np'`: Return a batch of type `np.ndarray`.
              - `TensorType.JAX` or `'jax'`: Return a batch of type `jax.numpy.ndarray`.
      data_format (`ChannelDimension` or `str`, *optional*, defaults to `ChannelDimension.FIRST`):
          The channel dimension format for the output image. Can be one of:
              - `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
              - `ChannelDimension.LAST`: image in (height, width, num_channels) format.
      input_data_format (`ChannelDimension` or `str`, *optional*):
          The channel dimension format for the input image. If unset, the channel dimension format is inferred
          from the input image. Can be one of:
          - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
          - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
          - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
docstr_tok: ["Preprocess","an","image","or","batch","of","images",".","Args",":","images","(","`","ImageInput","`",")",":","Image","to","preprocess",".","Expects","a","single","or","batch","of","images","with","pixel","values","ranging","from","0","to","255",".","If","passing","in","images","with","pixel","values","between","0","and","1",",","set","`","do_rescale=False","`",".","do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.do_resize","`",")",":","Whether","to","resize","the","image",".","size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","self.size","`",")",":","Size","of","the","image",".","resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.resample","`",")",":","Resampling","filter","to","use","if","resizing","the","image",".","This","can","be","one","of","the","enum","`","PILImageResampling","`",",","Only","has","an","effect","if","`","do_resize","`","is","set","to","`","True","`",".","do_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.do_center_crop","`",")",":","Whether","to","center","crop","the","image",".","crop_size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","self.crop_size","`",")",":","Size","of","the","center","crop",".","Only","has","an","effect","if","`","do_center_crop","`","is","set","to","`","True","`",".","do_rescale","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.do_rescale","`",")",":","Whether","to","rescale","the","image","values","between","[","0","-","1","]",".","rescale_factor","(","`","float","`",",","*","optional","*",",","defaults","to","`","self.rescale_factor","`",")",":","Rescale","factor","to","rescale","the","image","by","if","`","do_rescale","`","is","set","to","`","True","`",".","do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.do_normalize","`",")",":","Whether","to","normalize","the","image",".","image_mean","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","self.image_mean","`",")",":","Image","mean",".","image_std","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","self.image_std","`",")",":","Image","standard","deviation",".","return_image_mask","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.return_image_mask","`",")",":","Whether","to","return","the","image","mask",".","input_size_patches","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.input_size_patches","`",")",":","Size","of","the","patches","to","extract","from","the","image",".","total_mask_patches","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.total_mask_patches","`",")",":","Total","number","of","patches","to","extract","from","the","image",".","mask_group_min_patches","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.mask_group_min_patches","`",")",":","Minimum","number","of","patches","to","extract","from","the","image",".","mask_group_max_patches","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.mask_group_max_patches","`",")",":","Maximum","number","of","patches","to","extract","from","the","image",".","mask_group_min_aspect_ratio","(","`","float","`",",","*","optional","*",",","defaults","to","`","self.mask_group_min_aspect_ratio","`",")",":","Minimum","aspect","ratio","of","the","patches","to","extract","from","the","image",".","mask_group_max_aspect_ratio","(","`","float","`",",","*","optional","*",",","defaults","to","`","self.mask_group_max_aspect_ratio","`",")",":","Maximum","aspect","ratio","of","the","patches","to","extract","from","the","image",".","return_codebook_pixels","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.return_codebook_pixels","`",")",":","Whether","to","return","the","codebook","pixels",".","codebook_do_resize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.codebook_do_resize","`",")",":","Whether","to","resize","the","codebook","pixels",".","codebook_size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","self.codebook_size","`",")",":","Size","of","the","codebook","pixels",".","codebook_resample","(","`","int","`",",","*","optional","*",",","defaults","to","`","self.codebook_resample","`",")",":","Resampling","filter","to","use","if","resizing","the","codebook","pixels",".","This","can","be","one","of","the","enum","`","PILImageResampling","`",",","Only","has","an","effect","if","`","codebook_do_resize","`","is","set","to","`","True","`",".","codebook_do_center_crop","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.codebook_do_center_crop","`",")",":","Whether","to","center","crop","the","codebook","pixels",".","codebook_crop_size","(","`","Dict","[","str",",","int","]","`",",","*","optional","*",",","defaults","to","`","self.codebook_crop_size","`",")",":","Size","of","the","center","crop","of","the","codebook","pixels",".","Only","has","an","effect","if","`","codebook_do_center_crop","`","is","set","to","`","True","`",".","codebook_do_rescale","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.codebook_do_rescale","`",")",":","Whether","to","rescale","the","codebook","pixels","values","between","[","0","-","1","]",".","codebook_rescale_factor","(","`","float","`",",","*","optional","*",",","defaults","to","`","self.codebook_rescale_factor","`",")",":","Rescale","factor","to","rescale","the","codebook","pixels","by","if","`","codebook_do_rescale","`","is","set","to","`","True","`",".","codebook_do_map_pixels","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.codebook_do_map_pixels","`",")",":","Whether","to","map","the","codebook","pixels","values",".","codebook_do_normalize","(","`","bool","`",",","*","optional","*",",","defaults","to","`","self.codebook_do_normalize","`",")",":","Whether","to","normalize","the","codebook","pixels",".","codebook_image_mean","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","self.codebook_image_mean","`",")",":","Codebook","pixels","mean","to","normalize","the","codebook","pixels","by","if","`","codebook_do_normalize","`","is","set","to","`","True","`",".","codebook_image_std","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","self.codebook_image_std","`",")",":","Codebook","pixels","standard","deviation","to","normalize","the","codebook","pixels","by","if","`","codebook_do_normalize","`","is","set","to","`","True","`",".","return_tensors","(","`","str","`","or","`","TensorType","`",",","*","optional","*",")",":","The","type","of","tensors","to","return",".","Can","be","one","of",":","-","Unset",":","Return","a","list","of","`","np.ndarray","`",".","-","`","TensorType.TENSORFLOW","`","or","`","'tf","'","`",":","Return","a","batch","of","type","`","tf.Tensor","`",".","-","`","TensorType.PYTORCH","`","or","`","'pt","'","`",":","Return","a","batch","of","type","`","torch.Tensor","`",".","-","`","TensorType.NUMPY","`","or","`","'np","'","`",":","Return","a","batch","of","type","`","np.ndarray","`",".","-","`","TensorType.JAX","`","or","`","'jax","'","`",":","Return","a","batch","of","type","`","jax.numpy.ndarray","`",".","data_format","(","`","ChannelDimension","`","or","`","str","`",",","*","optional","*",",","defaults","to","`","ChannelDimension.FIRST","`",")",":","The","channel","dimension","format","for","the","output","image",".","Can","be","one","of",":","-","`","ChannelDimension.FIRST","`",":","image","in","(","num_channels",",","height",",","width",")","format",".","-","`","ChannelDimension.LAST","`",":","image","in","(","height",",","width",",","num_channels",")","format",".","input_data_format","(","`","ChannelDimension","`","or","`","str","`",",","*","optional","*",")",":","The","channel","dimension","format","for","the","input","image",".","If","unset",",","the","channel","dimension","format","is","inferred","from","the","input","image",".","Can","be","one","of",":","-","`","``","channels_first","''","`","or","`","ChannelDimension.FIRST","`",":","image","in","(","num_channels",",","height",",","width",")","format",".","-","`","``","channels_last","''","`","or","`","ChannelDimension.LAST","`",":","image","in","(","height",",","width",",","num_channels",")","format",".","-","`","``","none","''","`","or","`","ChannelDimension.NONE","`",":","image","in","(","height",",","width",")","format","."]
code: def preprocess(
      self,
      images: ImageInput,
      do_resize: Optional[bool] = None,
      size: Dict[str, int] = None,
      resample: PILImageResampling = None,
      do_center_crop: Optional[bool] = None,
      crop_size: Optional[Dict[str, int]] = None,
      do_rescale: Optional[bool] = None,
      rescale_factor: Optional[float] = None,
      do_normalize: Optional[bool] = None,
      image_mean: Optional[Union[float, List[float]]] = None,
      image_std: Optional[Union[float, List[float]]] = None,
      # Mask related params
      return_image_mask: Optional[bool] = None,
      input_size_patches: Optional[int] = None,
      total_mask_patches: Optional[int] = None,
      mask_group_min_patches: Optional[int] = None,
      mask_group_max_patches: Optional[int] = None,
      mask_group_min_aspect_ratio: Optional[float] = None,
      mask_group_max_aspect_ratio: Optional[float] = None,
      # Codebook related params
      return_codebook_pixels: Optional[bool] = None,
      codebook_do_resize: Optional[bool] = None,
      codebook_size: Optional[Dict[str, int]] = None,
      codebook_resample: Optional[int] = None,
      codebook_do_center_crop: Optional[bool] = None,
      codebook_crop_size: Optional[Dict[str, int]] = None,
      codebook_do_rescale: Optional[bool] = None,
      codebook_rescale_factor: Optional[float] = None,
      codebook_do_map_pixels: Optional[bool] = None,
      codebook_do_normalize: Optional[bool] = None,
      codebook_image_mean: Optional[Iterable[float]] = None,
      codebook_image_std: Optional[Iterable[float]] = None,
      return_tensors: Optional[Union[str, TensorType]] = None,
      data_format: ChannelDimension = ChannelDimension.FIRST,
      input_data_format: Optional[Union[str, ChannelDimension]] = None,
      **kwargs,
  ) -> PIL.Image.Image:
      """
      Preprocess an image or batch of images.
  
      Args:
          images (`ImageInput`):
              Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
              passing in images with pixel values between 0 and 1, set `do_rescale=False`.
          do_resize (`bool`, *optional*, defaults to `self.do_resize`):
              Whether to resize the image.
          size (`Dict[str, int]`, *optional*, defaults to `self.size`):
              Size of the image.
          resample (`int`, *optional*, defaults to `self.resample`):
              Resampling filter to use if resizing the image. This can be one of the enum `PILImageResampling`, Only
              has an effect if `do_resize` is set to `True`.
          do_center_crop (`bool`, *optional*, defaults to `self.do_center_crop`):
              Whether to center crop the image.
          crop_size (`Dict[str, int]`, *optional*, defaults to `self.crop_size`):
              Size of the center crop. Only has an effect if `do_center_crop` is set to `True`.
          do_rescale (`bool`, *optional*, defaults to `self.do_rescale`):
              Whether to rescale the image values between [0 - 1].
          rescale_factor (`float`, *optional*, defaults to `self.rescale_factor`):
              Rescale factor to rescale the image by if `do_rescale` is set to `True`.
          do_normalize (`bool`, *optional*, defaults to `self.do_normalize`):
              Whether to normalize the image.
          image_mean (`float` or `List[float]`, *optional*, defaults to `self.image_mean`):
              Image mean.
          image_std (`float` or `List[float]`, *optional*, defaults to `self.image_std`):
              Image standard deviation.
          return_image_mask (`bool`, *optional*, defaults to `self.return_image_mask`):
              Whether to return the image mask.
          input_size_patches (`int`, *optional*, defaults to `self.input_size_patches`):
              Size of the patches to extract from the image.
          total_mask_patches (`int`, *optional*, defaults to `self.total_mask_patches`):
              Total number of patches to extract from the image.
          mask_group_min_patches (`int`, *optional*, defaults to `self.mask_group_min_patches`):
              Minimum number of patches to extract from the image.
          mask_group_max_patches (`int`, *optional*, defaults to `self.mask_group_max_patches`):
              Maximum number of patches to extract from the image.
          mask_group_min_aspect_ratio (`float`, *optional*, defaults to `self.mask_group_min_aspect_ratio`):
              Minimum aspect ratio of the patches to extract from the image.
          mask_group_max_aspect_ratio (`float`, *optional*, defaults to `self.mask_group_max_aspect_ratio`):
              Maximum aspect ratio of the patches to extract from the image.
          return_codebook_pixels (`bool`, *optional*, defaults to `self.return_codebook_pixels`):
              Whether to return the codebook pixels.
          codebook_do_resize (`bool`, *optional*, defaults to `self.codebook_do_resize`):
              Whether to resize the codebook pixels.
          codebook_size (`Dict[str, int]`, *optional*, defaults to `self.codebook_size`):
              Size of the codebook pixels.
          codebook_resample (`int`, *optional*, defaults to `self.codebook_resample`):
              Resampling filter to use if resizing the codebook pixels. This can be one of the enum
              `PILImageResampling`, Only has an effect if `codebook_do_resize` is set to `True`.
          codebook_do_center_crop (`bool`, *optional*, defaults to `self.codebook_do_center_crop`):
              Whether to center crop the codebook pixels.
          codebook_crop_size (`Dict[str, int]`, *optional*, defaults to `self.codebook_crop_size`):
              Size of the center crop of the codebook pixels. Only has an effect if `codebook_do_center_crop` is set
              to `True`.
          codebook_do_rescale (`bool`, *optional*, defaults to `self.codebook_do_rescale`):
              Whether to rescale the codebook pixels values between [0 - 1].
          codebook_rescale_factor (`float`, *optional*, defaults to `self.codebook_rescale_factor`):
              Rescale factor to rescale the codebook pixels by if `codebook_do_rescale` is set to `True`.
          codebook_do_map_pixels (`bool`, *optional*, defaults to `self.codebook_do_map_pixels`):
              Whether to map the codebook pixels values.
          codebook_do_normalize (`bool`, *optional*, defaults to `self.codebook_do_normalize`):
              Whether to normalize the codebook pixels.
          codebook_image_mean (`float` or `List[float]`, *optional*, defaults to `self.codebook_image_mean`):
              Codebook pixels mean to normalize the codebook pixels by if `codebook_do_normalize` is set to `True`.
          codebook_image_std (`float` or `List[float]`, *optional*, defaults to `self.codebook_image_std`):
              Codebook pixels standard deviation to normalize the codebook pixels by if `codebook_do_normalize` is
              set to `True`.
          return_tensors (`str` or `TensorType`, *optional*):
              The type of tensors to return. Can be one of:
                  - Unset: Return a list of `np.ndarray`.
                  - `TensorType.TENSORFLOW` or `'tf'`: Return a batch of type `tf.Tensor`.
                  - `TensorType.PYTORCH` or `'pt'`: Return a batch of type `torch.Tensor`.
                  - `TensorType.NUMPY` or `'np'`: Return a batch of type `np.ndarray`.
                  - `TensorType.JAX` or `'jax'`: Return a batch of type `jax.numpy.ndarray`.
          data_format (`ChannelDimension` or `str`, *optional*, defaults to `ChannelDimension.FIRST`):
              The channel dimension format for the output image. Can be one of:
                  - `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
                  - `ChannelDimension.LAST`: image in (height, width, num_channels) format.
          input_data_format (`ChannelDimension` or `str`, *optional*):
              The channel dimension format for the input image. If unset, the channel dimension format is inferred
              from the input image. Can be one of:
              - `"channels_first"` or `ChannelDimension.FIRST`: image in (num_channels, height, width) format.
              - `"channels_last"` or `ChannelDimension.LAST`: image in (height, width, num_channels) format.
              - `"none"` or `ChannelDimension.NONE`: image in (height, width) format.
      """
      do_resize = do_resize if do_resize is not None else self.do_resize
      size = size if size is not None else self.size
      size = get_size_dict(size)
      resample = resample if resample is not None else self.resample
      do_center_crop = (
          do_center_crop
          if do_center_crop is not None
          else self.do_center_crop
      )
      crop_size = crop_size if crop_size is not None else self.crop_size
      crop_size = get_size_dict(crop_size, param_name="crop_size")
      do_rescale = (
          do_rescale if do_rescale is not None else self.do_rescale
      )
      rescale_factor = (
          rescale_factor
          if rescale_factor is not None
          else self.rescale_factor
      )
      do_normalize = (
          do_normalize
          if do_normalize is not None
          else self.do_normalize
      )
      image_mean = (
          image_mean if image_mean is not None else self.image_mean
      )
      image_std = image_std if image_std is not None else self.image_std
  
      return_image_mask = (
          return_image_mask
          if return_image_mask is not None
          else self.return_image_mask
      )
      input_size_patches = (
          input_size_patches
          if input_size_patches is not None
          else self.input_size_patches
      )
      total_mask_patches = (
          total_mask_patches
          if total_mask_patches is not None
          else self.total_mask_patches
      )
      mask_group_min_patches = (
          mask_group_min_patches
          if mask_group_min_patches is not None
          else self.mask_group_min_patches
      )
      mask_group_max_patches = (
          mask_group_max_patches
          if mask_group_max_patches is not None
          else self.mask_group_max_patches
      )
      mask_group_min_aspect_ratio = (
          mask_group_min_aspect_ratio
          if mask_group_min_aspect_ratio is not None
          else self.mask_group_min_aspect_ratio
      )
      mask_group_max_aspect_ratio = (
          mask_group_max_aspect_ratio
          if mask_group_max_aspect_ratio is not None
          else self.mask_group_max_aspect_ratio
      )
  
      return_codebook_pixels = (
          return_codebook_pixels
          if return_codebook_pixels is not None
          else self.return_codebook_pixels
      )
      codebook_do_resize = (
          codebook_do_resize
          if codebook_do_resize is not None
          else self.codebook_do_resize
      )
      codebook_size = (
          codebook_size
          if codebook_size is not None
          else self.codebook_size
      )
      codebook_size = get_size_dict(
          codebook_size, param_name="codebook_size"
      )
      codebook_resample = (
          codebook_resample
          if codebook_resample is not None
          else self.codebook_resample
      )
      codebook_do_rescale = (
          codebook_do_rescale
          if codebook_do_rescale is not None
          else self.codebook_do_rescale
      )
      codebook_rescale_factor = (
          codebook_rescale_factor
          if codebook_rescale_factor is not None
          else self.codebook_rescale_factor
      )
      codebook_do_center_crop = (
          codebook_do_center_crop
          if codebook_do_center_crop is not None
          else self.codebook_do_center_crop
      )
      codebook_crop_size = (
          codebook_crop_size
          if codebook_crop_size is not None
          else self.codebook_crop_size
      )
      codebook_crop_size = get_size_dict(
          codebook_crop_size, param_name="codebook_crop_size"
      )
      codebook_do_map_pixels = (
          codebook_do_map_pixels
          if codebook_do_map_pixels is not None
          else self.codebook_do_map_pixels
      )
      codebook_do_normalize = (
          codebook_do_normalize
          if codebook_do_normalize is not None
          else self.codebook_do_normalize
      )
      codebook_image_mean = (
          codebook_image_mean
          if codebook_image_mean is not None
          else self.codebook_image_mean
      )
      codebook_image_std = (
          codebook_image_std
          if codebook_image_std is not None
          else self.codebook_image_std
      )
  
      images = make_list_of_images(images)
  
      if not valid_images(images):
          raise ValueError(
              "Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, "
              "torch.Tensor, tf.Tensor or jax.ndarray."
          )
  
      processed_images = [
          self._preprocess_image(
              image=img,
              do_resize=do_resize,
              size=size,
              resample=resample,
              do_center_crop=do_center_crop,
              crop_size=crop_size,
              do_rescale=do_rescale,
              rescale_factor=rescale_factor,
              do_normalize=do_normalize,
              image_mean=image_mean,
              image_std=image_std,
              do_map_pixels=False,
              data_format=data_format,
              input_data_format=input_data_format,
          )
          for img in images
      ]
      data = {"pixel_values": processed_images}
  
      if return_codebook_pixels:
          codebook_images = [
              self._preprocess_image(
                  image=img,
                  do_resize=codebook_do_resize,
                  size=codebook_size,
                  resample=codebook_resample,
                  do_center_crop=codebook_do_center_crop,
                  crop_size=codebook_crop_size,
                  do_rescale=codebook_do_rescale,
                  rescale_factor=codebook_rescale_factor,
                  do_normalize=codebook_do_normalize,
                  image_mean=codebook_image_mean,
                  image_std=codebook_image_std,
                  do_map_pixels=codebook_do_map_pixels,
                  data_format=data_format,
                  input_data_format=input_data_format,
              )
              for img in images
          ]
          data["codebook_pixel_values"] = codebook_images
  
      if return_image_mask:
          mask_generator = self.masking_generator(
              input_size_patches=input_size_patches,
              total_mask_patches=total_mask_patches,
              mask_group_min_patches=mask_group_min_patches,
              mask_group_max_patches=mask_group_max_patches,
              mask_group_min_aspect_ratio=mask_group_min_aspect_ratio,
              mask_group_max_aspect_ratio=mask_group_max_aspect_ratio,
          )
          masks = [mask_generator() for _ in images]
          data["bool_masked_pos"] = masks
  
      return BatchFeature(data=data, tensor_type=return_tensors)
  
imports: import math
  import random
  from functools import lru_cache
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  import numpy
  from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
  from ...image_transforms import resize, to_channel_dimension_format
  from ...image_utils import OPENAI_CLIP_MEAN, OPENAI_CLIP_STD, ChannelDimension, ImageInput, PILImageResampling, infer_channel_dimension_format, is_scaled_image, make_list_of_images, to_numpy_array, valid_images
  from ...utils import TensorType, is_vision_available, logging
label_desc: Use image node_id 7 for calling the FlavaImageProcessor obj's underlying member method code with example usage: obj.preprocess(images, do_resize, size, resample, do_center_crop, crop_size, do_rescale, rescale_factor, do_normalize, image_mean, image_std, return_image_mask, input_size_patches, total_mask_patches, mask_group_min_patches, mask_group_max_patches, mask_group_min_aspect_ratio, mask_group_max_aspect_ratio, return_codebook_pixels, codebook_do_resize, codebook_size, codebook_resample, codebook_do_center_crop, codebook_crop_size, codebook_do_rescale, codebook_rescale_factor, codebook_do_map_pixels, codebook_do_normalize, codebook_image_mean, codebook_image_std, return_tensors, data_format, input_data_format) and returns: BatchFeature