code: def main():
      args = parse_args()
      video_file = args.video_file
      feat_dir = args.feat_dir
      infer_batch = args.infer_batch
      feat_path = (
          os.path.join(feat_dir, os.path.basename(video_file))
          .replace(".mp4", ".pkl")
          .replace(".mkv", ".pkl")
      )
      print(feat_path)
  
      # Initialize the CLIP model
      vision_tower = "./model_zoo/LAVIS/eva_vit_g.pth"
      image_processor = "./model_zoo/OpenAI/clip-vit-large-patch14"
      vision_tower = EVAVisionTowerLavis(
          vision_tower, image_processor, args=None
      ).cuda()
      vision_tower.eval()
      image_processor = vision_tower.image_processor
  
      subtitles = load_subtitles(video_file)
      video, frame_time = load_video(video_file, sample_fps=args.fps)
      video_input = load_video_input(subtitles, frame_time)
  
      video_tensor = image_processor.preprocess(
          video, return_tensors="pt"
      )["pixel_values"].half()
      print(video_tensor.shape)
  
      n_chunk = len(video_tensor)
      video_features = torch.FloatTensor(n_chunk, 257, 1408).fill_(0)
      n_iter = int(math.ceil(n_chunk / float(infer_batch)))
      for i in range(n_iter):
          min_ind = i * infer_batch
          max_ind = min((i + 1) * infer_batch, n_chunk)
          video_batch = video_tensor[min_ind:max_ind].cuda()
          batch_features = vision_tower(video_batch)
          video_features[
              min_ind:max_ind
          ] = batch_features.detach().cpu()
      video_features = video_features.numpy().astype("float16")
      print(video_features.shape)
      video_info = dict(feats=video_features, inputs=video_input)
  
      with open(feat_path, "wb") as f:
          pickle.dump(video_info, f)
  
file_path: llama-vid/scripts/extra_tool/extract_video_features_subtitles.py
imports: import os
  import math
  import json
  import torch
  import pickle
  import argparse
  import numpy
  from decord import VideoReader, cpu
  from transformers import CLIPVisionModel, CLIPImageProcessor
  from llamavid.model.multimodal_encoder.eva_vit import EVAVisionTowerLavis
  import whisper
label_desc: Use image node_id 5 for calling a global function with example usage: main() without return types