code: def preprocess_video(video):
      supported_formats = (np.ndarray, torch.Tensor, PIL.Image.Image)
  
      if isinstance(video, supported_formats):
          video = [video]
      elif not (
          isinstance(video, list)
          and all(isinstance(i, supported_formats) for i in video)
      ):
          raise ValueError(
              f"Input is in incorrect format: {[type(i) for i in video]}. Currently, we only support {', '.join(supported_formats)}"
          )
  
      if isinstance(video[0], PIL.Image.Image):
          video = [np.array(frame) for frame in video]
  
      if isinstance(video[0], np.ndarray):
          video = (
              np.concatenate(video, axis=0)
              if video[0].ndim == 5
              else np.stack(video, axis=0)
          )
  
          if video.dtype == np.uint8:
              video = np.array(video).astype(np.float32) / 255.0
  
          if video.ndim == 4:
              video = video[None, ...]
  
          video = torch.from_numpy(video.transpose(0, 4, 1, 2, 3))
  
      elif isinstance(video[0], torch.Tensor):
          video = (
              torch.cat(video, axis=0)
              if video[0].ndim == 5
              else torch.stack(video, axis=0)
          )
  
          # don't need any preprocess if the video is latents
          channel = video.shape[1]
          if channel == 4:
              return video
  
          # move channels before num_frames
          video = video.permute(0, 2, 1, 3, 4)
  
      # normalize video
      video = 2.0 * video - 1.0
  
      return video
  
imports: import inspect
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from transformers import CLIPTextModel, CLIPTokenizer
  from ...loaders import LoraLoaderMixin, TextualInversionLoaderMixin
  from ...models import AutoencoderKL, UNet3DConditionModel
  from ...models.lora import adjust_lora_scale_text_encoder
  from ...schedulers import KarrasDiffusionSchedulers
  from ...utils import USE_PEFT_BACKEND, deprecate, logging, replace_example_docstring, scale_lora_layers, unscale_lora_layers
  from ...utils.torch_utils import randn_tensor
  from ..pipeline_utils import DiffusionPipeline
  from .None import TextToVideoSDPipelineOutput
label_desc: Use image node_id 3 for calling a global function with example usage: preprocess_video(video) and returns: video, video