code: def infer_channel_dimension_format(
      image: np.ndarray,
  ) -> ChannelDimension:
      """
      Infers the channel dimension format of `image`.
  
      Args:
          image (`np.ndarray`):
              The image to infer the channel dimension of.
  
      Returns:
          The channel dimension of the image.
      """
      if image.ndim == 3:
          first_dim, last_dim = 0, 2
      elif image.ndim == 4:
          first_dim, last_dim = 1, 3
      else:
          raise ValueError(
              f"Unsupported number of image dimensions: {image.ndim}"
          )
  
      if image.shape[first_dim] in (1, 3):
          return ChannelDimension.FIRST
      elif image.shape[last_dim] in (1, 3):
          return ChannelDimension.LAST
      raise ValueError("Unable to infer channel dimension format")
  
imports: import os
  from typing import TYPE_CHECKING, List, Tuple, Union
  import numpy
  from packaging import version
  import requests
  from .utils import ExplicitEnum, is_jax_tensor, is_tf_tensor, is_torch_available, is_torch_tensor, is_vision_available, to_numpy
  from .utils.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD
label_desc: Use image node_id 5 for calling a global function with example usage: infer_channel_dimension_format(image) and returns: ChannelDimension, ChannelDimension