code: def recognize_image_format(image) -> str:
      """Checks the image format and returns "numpy" or "file"."""
  
      # Check for numpy array.
      if isinstance(image, np.ndarray):
          if len(image.shape) == 3 and (image.shape[0] in [1, 3]):
              return "numpy"
          else:
              raise ValueError(
                  "Shape of image not understood, should be "
                  "color_channels (1 or 3) x height x width, "
                  f"is: {image.shape}"
              )
  
      # TODO: Check for torch tensor.
  
      # Check for path to directory.
      try:
          if Path(image).exists():
              # TODO: Maybe check that image can be read.
              return "files"
          else:
              raise FileNotFoundError(
                  f"Image path does not exist: {image}"
              )
      except TypeError:  # not a file or dir
          pass
  
      # If all checks failed...
      raise ValueError(
          "Image format not recognized. Supported formats: numpy arrays, path to image "
          "file"
      )
  
imports: import numpy
  import torch
  from torch.utils.data import Dataset
  from torchvision import datasets, transforms
  from typing import List, Union
  from pathlib import Path
  from PIL import Image
label_desc: Use image node_id 4 for calling a global function with example usage: recognize_image_format(image) and returns: str, str