code: def normalize(
      image: np.ndarray,
      mean: Union[float, Iterable[float]],
      std: Union[float, Iterable[float]],
      data_format: Optional[ChannelDimension] = None,
  ) -> np.ndarray:
      """
      Normalizes `image` using the mean and standard deviation specified by `mean` and `std`.
  
      image = (image - mean) / std
  
      Args:
          image (`np.ndarray`):
              The image to normalize.
          mean (`float` or `Iterable[float]`):
              The mean to use for normalization.
          std (`float` or `Iterable[float]`):
              The standard deviation to use for normalization.
          data_format (`ChannelDimension`, *optional*):
              The channel dimension format of the output image. If `None`, will use the inferred format from the input.
      """
      if isinstance(image, PIL.Image.Image):
          warnings.warn(
              "PIL.Image.Image inputs are deprecated and will be removed in v4.26.0. Please use numpy arrays instead.",
              FutureWarning,
          )
          # Convert PIL image to numpy array with the same logic as in the previous feature extractor normalize -
          # casting to numpy array and dividing by 255.
          image = to_numpy_array(image)
          image = rescale(image, scale=1 / 255)
  
      input_data_format = infer_channel_dimension_format(image)
      channel_axis = get_channel_dimension_axis(image)
      num_channels = image.shape[channel_axis]
  
      if isinstance(mean, Iterable):
          if len(mean) != num_channels:
              raise ValueError(
                  f"mean must have {num_channels} elements if it is an iterable, got {len(mean)}"
              )
      else:
          mean = [mean] * num_channels
  
      if isinstance(std, Iterable):
          if len(std) != num_channels:
              raise ValueError(
                  f"std must have {num_channels} elements if it is an iterable, got {len(std)}"
              )
      else:
          std = [std] * num_channels
  
      if input_data_format == ChannelDimension.LAST:
          image = (image - mean) / std
      else:
          image = ((image.T - mean) / std).T
  
      image = (
          to_channel_dimension_format(image, data_format)
          if data_format is not None
          else image
      )
      return image
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/src/transformers/image_transforms.py
imports: import warnings
  from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union
  import numpy
  from transformers.image_utils import PILImageResampling
  from transformers.utils.import_utils import is_flax_available, is_tf_available, is_torch_available, is_vision_available
label_desc: Use image node_id 6 for calling a global function with example usage: normalize(image, mean, std, data_format) and returns: image