class_docstr: Constructs a Idefics image processor.
  Args:
      image_size (`int`, *optional*, defaults to `224`):
          Resize to image size
      image_num_channels (`int`, *optional*, defaults to `3`):
          Number of image channels.
      image_mean (`float` or `List[float]`, *optional*, defaults to `IDEFICS_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. Can be
          overridden by the `image_mean` parameter in the `preprocess` method.
      image_std (`float` or `List[float]`, *optional*, defaults to `IDEFICS_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.
          Can be overridden by the `image_std` parameter in the `preprocess` method.
class_docstr_tok: ["Constructs","a","Idefics","image","processor",".","Args",":","image_size","(","`","int","`",",","*","optional","*",",","defaults","to","`","224","`",")",":","Resize","to","image","size","image_num_channels","(","`","int","`",",","*","optional","*",",","defaults","to","`","3","`",")",":","Number","of","image","channels",".","image_mean","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","IDEFICS_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",".","Can","be","overridden","by","the","`","image_mean","`","parameter","in","the","`","preprocess","`","method",".","image_std","(","`","float","`","or","`","List","[","float","]","`",",","*","optional","*",",","defaults","to","`","IDEFICS_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",".","Can","be","overridden","by","the","`","image_std","`","parameter","in","the","`","preprocess","`","method","."]
docstr: Rescale an image by a scale factor. image = image * scale.
  
  Args:
      image (`np.ndarray`):
          Image to rescale.
      scale (`float`):
          The scaling factor to rescale pixel values by.
      data_format (`str` or `ChannelDimension`, *optional*):
          The channel dimension format for the output image. If unset, the channel dimension format of the input
          image is used. 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.
      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.
  
  Returns:
      `np.ndarray`: The rescaled image.
docstr_tok: ["Rescale","an","image","by","a","scale","factor",".","image","=","image","*","scale",".","Args",":","image","(","`","np.ndarray","`",")",":","Image","to","rescale",".","scale","(","`","float","`",")",":","The","scaling","factor","to","rescale","pixel","values","by",".","data_format","(","`","str","`","or","`","ChannelDimension","`",",","*","optional","*",")",":","The","channel","dimension","format","for","the","output","image",".","If","unset",",","the","channel","dimension","format","of","the","input","image","is","used",".","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",".","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",".","Returns",":","`","np.ndarray","`",":","The","rescaled","image","."]
code: def rescale(
      self,
      image: np.ndarray,
      scale: float,
      data_format: Optional[Union[str, ChannelDimension]] = None,
      input_data_format: Optional[Union[str, ChannelDimension]] = None,
      **kwargs,
  ) -> np.ndarray:
      """
      Rescale an image by a scale factor. image = image * scale.
  
      Args:
          image (`np.ndarray`):
              Image to rescale.
          scale (`float`):
              The scaling factor to rescale pixel values by.
          data_format (`str` or `ChannelDimension`, *optional*):
              The channel dimension format for the output image. If unset, the channel dimension format of the input
              image is used. 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.
          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.
  
      Returns:
          `np.ndarray`: The rescaled image.
      """
      # return rescale(image, scale=scale, data_format=data_format, input_data_format=input_data_format, **kwargs)
      # requires 4.32
      return rescale(
          image, scale=scale, data_format=data_format, **kwargs
      )
  
file_path: text-generation-inference/server/text_generation_server/models/custom_modeling/idefics_image_processing.py
imports: from typing import Callable, Dict, List, Optional, Union, Iterable
  import numpy
  from PIL import Image
  from transformers.image_processing_utils import BaseImageProcessor, BatchFeature
  from transformers.image_transforms import resize, to_channel_dimension_format, rescale, normalize
  from transformers.image_utils import ChannelDimension, ImageInput, PILImageResampling, make_list_of_images, to_numpy_array, valid_images
  from io import BytesIO
  import base64
  import requests
  from transformers import TensorType, is_torch_available
  import transformers
label_desc: Use image node_id 4 for calling the IdeficsImageProcessor obj's underlying member method code with example usage: obj.rescale(image, scale, data_format, input_data_format) and returns: rescale