code: def validate_and_load_image(
      image: Union[str, Image.Image]
  ) -> Image.Image:
      """
      If image is a str, loads the image as a PIL Image and returns it. Otherwise,
      we assert that image is a PIL Image and then return it.
      """
      if isinstance(image, str):
          local_path = utils.pathmgr.get_local_path(image)
          utils.validate_image_path(local_path)
          return Image.open(local_path)
  
      assert isinstance(
          image, Image.Image
      ), "Expected type PIL.Image.Image for variable 'image'"
  
      return image
  
file_path: AugLy/augly/image/utils/utils.py
imports: import functools
  import json
  import math
  import os
  from typing import List, Optional, Tuple, Union
  import numpy
  from augly import utils
  from PIL import Image
label_desc: Use image node_id 1 for calling a global function with example usage: validate_and_load_image(image) and returns: image, Image