code: def tensor2vid(video: torch.Tensor, processor, output_type="np"):
      # Based on:
      # https://github.com/modelscope/modelscope/blob/1509fdb973e5871f37148a4b5e5964cafd43e64d/modelscope/pipelines/multi_modal/text_to_video_synthesis_pipeline.py#L78
  
      batch_size, channels, num_frames, height, width = video.shape
      outputs = []
      for batch_idx in range(batch_size):
          batch_vid = video[batch_idx].permute(1, 0, 2, 3)
          batch_output = processor.postprocess(batch_vid, output_type)
  
          outputs.append(batch_output)
  
      if output_type == "np":
          return np.stack(outputs)
  
      return outputs
  
imports: import inspect
  from dataclasses import dataclass
  from typing import Callable, Dict, List, Optional, Union
  import numpy
  import PIL.Image
  import torch
  from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection
  from ...image_processor import VaeImageProcessor
  from ...models import AutoencoderKLTemporalDecoder, UNetSpatioTemporalConditionModel
  from ...schedulers import EulerDiscreteScheduler
  from ...utils import BaseOutput, logging
  from ...utils.torch_utils import is_compiled_module, randn_tensor
  from ..pipeline_utils import DiffusionPipeline
label_desc: Use image node_id 2 for calling a global function with example usage: tensor2vid(video, processor, output_type) and returns: outputs, np