code: def _preprocess_adapter_image(image, height, width):
      if isinstance(image, torch.Tensor):
          return image
      elif isinstance(image, PIL.Image.Image):
          image = [image]
  
      if isinstance(image[0], PIL.Image.Image):
          image = [
              np.array(
                  i.resize(
                      (width, height),
                      resample=PIL_INTERPOLATION["lanczos"],
                  )
              )
              for i in image
          ]
          image = [
              i[None, ..., None] if i.ndim == 2 else i[None, ...]
              for i in image
          ]  # expand [h, w] or [h, w, c] to [b, h, w, c]
          image = np.concatenate(image, axis=0)
          image = np.array(image).astype(np.float32) / 255.0
          image = image.transpose(0, 3, 1, 2)
          image = torch.from_numpy(image)
      elif isinstance(image[0], torch.Tensor):
          if image[0].ndim == 3:
              image = torch.stack(image, dim=0)
          elif image[0].ndim == 4:
              image = torch.cat(image, dim=0)
          else:
              raise ValueError(
                  f"Invalid image tensor! Expecting image tensor with 3 or 4 dimension, but recive: {image[0].ndim}"
              )
      return image
  
imports: import inspect
  from dataclasses import dataclass
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
  from ...image_processor import VaeImageProcessor
  from ...loaders import LoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AutoencoderKL, MultiAdapter, T2IAdapter, UNet2DConditionModel
  from ...models.lora import adjust_lora_scale_text_encoder
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import PIL_INTERPOLATION, USE_PEFT_BACKEND, BaseOutput, deprecate, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from ..stable_diffusion.safety_checker import StableDiffusionSafetyChecker
label_desc: Use image node_id 1 for calling a global function with example usage: _preprocess_adapter_image(image, height, width) and returns: image, image