code: def export_to_video(
      video_frames: Union[List[np.ndarray], List[PIL.Image.Image]],
      output_video_path: str = None,
      fps: int = 8,
  ) -> str:
      if is_opencv_available():
          import cv2
      else:
          raise ImportError(
              BACKENDS_MAPPING["opencv"][1].format("export_to_video")
          )
      if output_video_path is None:
          output_video_path = tempfile.NamedTemporaryFile(
              suffix=".mp4"
          ).name
  
      if isinstance(video_frames[0], PIL.Image.Image):
          video_frames = [np.array(frame) for frame in video_frames]
  
      fourcc = cv2.VideoWriter_fourcc(*"mp4v")
      h, w, c = video_frames[0].shape
      video_writer = cv2.VideoWriter(
          output_video_path, fourcc, fps=fps, frameSize=(w, h)
      )
      for i in range(len(video_frames)):
          img = cv2.cvtColor(video_frames[i], cv2.COLOR_RGB2BGR)
          video_writer.write(img)
      return output_video_path
  
file_path: diffusers/src/diffusers/utils/export_utils.py
imports: import io
  import random
  import struct
  import tempfile
  from contextlib import contextmanager
  from typing import List, Union
  import numpy
  import PIL.Image
  import PIL.ImageOps
  from .import_utils import BACKENDS_MAPPING, is_opencv_available
  from .logging import get_logger
label_desc: Use image node_id 5 for calling a global function with example usage: export_to_video(video_frames, output_video_path, fps) and returns: output_video_path