code: def prepare_image(image):
      if isinstance(image, torch.Tensor):
          # Batch single image
          if image.ndim == 3:
              image = image.unsqueeze(0)
  
          image = image.to(dtype=torch.float32)
      else:
          # preprocess image
          if isinstance(image, (PIL.Image.Image, np.ndarray)):
              image = [image]
  
          if isinstance(image, list) and isinstance(
              image[0], PIL.Image.Image
          ):
              image = [
                  np.array(i.convert("RGB"))[None, :] for i in image
              ]
              image = np.concatenate(image, axis=0)
          elif isinstance(image, list) and isinstance(
              image[0], np.ndarray
          ):
              image = np.concatenate(
                  [i[None, :] for i in image], axis=0
              )
  
          image = image.transpose(0, 3, 1, 2)
          image = (
              torch.from_numpy(image).to(dtype=torch.float32) / 127.5
              - 1.0
          )
  
      return image
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import PIL.Image
  import torch
  import torch.nn.functional
  from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
  from diffusers import AutoencoderKL, ControlNetModel, DiffusionPipeline, UNet2DConditionModel, logging
  from diffusers.pipelines.controlnet.multicontrolnet import MultiControlNetModel
  from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput, StableDiffusionSafetyChecker
  from diffusers.schedulers import KarrasDiffusionSchedulers
  from diffusers.utils import PIL_INTERPOLATION, is_accelerate_available, is_accelerate_version, replace_example_docstring
  from diffusers.utils.torch_utils import randn_tensor
label_desc: Use image node_id 1 for calling a global function with example usage: prepare_image(image) and returns: image