code: def generate_video(
      data_sample: DataSample,
      force_encode=False,
      overwrite=False,
      **kwargs,
  ):
      new_file = get_vis_video_location(data_sample)
      if (os.path.isfile(new_file) and not overwrite) and not (
          force_encode and os.path.islink(new_file)
      ):
          return
      os.makedirs(os.path.dirname(new_file), exist_ok=True)
  
      video_file = data_sample.data_path
      #### Generate Video ####
      if os.path.isdir(video_file):
          # the data is a set of images, generate a video
          img_files = [
              os.path.join(video_file, f)
              for f in sorted(os.listdir(video_file))
          ]
          write_img_files_to_vid_ffmpeg(
              out_file=new_file,
              in_files=img_files,
              fps=data_sample.metadata["fps"],
          )
      else:
          if not video_file.endswith(".mp4") or force_encode:
              # Convert the video to mp4
              convert_vid_ffmpeg(video_file, new_file, **kwargs)
          else:
              # the data is a video, symlink to it
              if os.path.exists(new_file):
                  os.remove(new_file)
              os.symlink(video_file, new_file)
  
      return new_file
  
file_path: gluon-cv/gluoncv/torch/data/gluoncv_motion_dataset/dataset_pre_processor.py
imports: import os
  import random
  import logging
  import ray
  from pathlib import Path
  from tqdm import tqdm
  from .io.video_io import VideoFrameReader, write_img_files_to_vid_ffmpeg, resize_and_write_video_ffmpeg, convert_vid_ffmpeg
  from .utils.serialization_utils import save_json
  from .dataset import GluonCVMotionDataset, DataSample, FieldNames, get_resized_video_location, get_vis_gt_location, get_vis_thumb_location, get_vis_video_location
label_desc: Use image node_id 2 for calling a global function with example usage: generate_video(data_sample, force_encode, overwrite) and returns: new_file