code: def tensor2vid(
      video: torch.Tensor, mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5]
  ) -> List[np.ndarray]:
      # This code is copied from https://github.com/modelscope/modelscope/blob/1509fdb973e5871f37148a4b5e5964cafd43e64d/modelscope/pipelines/multi_modal/text_to_video_synthesis_pipeline.py#L78
      # reshape to ncfhw
      mean = torch.tensor(mean, device=video.device).reshape(
          1, -1, 1, 1, 1
      )
      std = torch.tensor(std, device=video.device).reshape(
          1, -1, 1, 1, 1
      )
      # unnormalize back to [0,1]
      video = video.mul_(std).add_(mean)
      video.clamp_(0, 1)
      # prepare the final outputs
      i, c, f, h, w = video.shape
      images = video.permute(2, 3, 0, 4, 1).reshape(
          f, h, i * w, c
      )  # 1st (frames, h, batch_size, w, c) 2nd (frames, h, batch_size * w, c)
      images = images.unbind(
          dim=0
      )  # prepare a list of indvidual (consecutive frames)
      images = [
          (image.cpu().numpy() * 255).astype("uint8")
          for image in images
      ]  # f h w c
      return images
  
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 2 for calling a global function with example usage: tensor2vid(video, mean, std) and returns: images