code: def annotate(prediction_set, caption_files, output_dir):
      """
      Evaluates question and answer pairs using GPT-3 and
      returns a score for temporal understanding.
      """
      for file in caption_files:
          key = file[:-5]  # Strip file extension
          qa_set = prediction_set[key]
          question = qa_set["q"]
          answer = qa_set["a"]
          pred = qa_set["pred"]
          try:
              print(key, "query")
              # Compute the temporal understanding score
              completion = openai.ChatCompletion.create(
                  model="gpt-3.5-turbo",
                  messages=[
                      {
                          "role": "system",
                          "content": "You are an intelligent chatbot designed for evaluating the temporal understanding of generative outputs for video-based question-answer pairs. "
                          "Your task is to compare the predicted answer with the correct answer and determine if they correctly reflect the temporal sequence of events in the video content. Here's how you can accomplish the task:"
                          "------"
                          "##INSTRUCTIONS: "
                          "- Focus on the temporal consistency between the predicted answer and the correct answer. The predicted answer should correctly reflect the sequence of events or details as they are presented in the video content.\n"
                          "- Consider synonyms or paraphrases as valid matches, but only if the temporal order is maintained.\n"
                          "- Evaluate the temporal accuracy of the prediction compared to the answer.",
                      },
                      {
                          "role": "user",
                          "content": "Please evaluate the following video-based question-answer pair:\n\n"
                          f"Question: {question}\n"
                          f"Correct Answer: {answer}\n"
                          f"Predicted Answer: {pred}\n\n"
                          "Provide your evaluation only as a temporal accuracy score where the temporal accuracy score is an integer value between 0 and 5, with 5 indicating the highest level of temporal consistency. "
                          "Please generate the response in the form of a Python dictionary string with keys 'score', where its value is the temporal accuracy score in INTEGER, not STRING."
                          "DO NOT PROVIDE ANY OTHER OUTPUT TEXT OR EXPLANATION. Only provide the Python dictionary string. "
                          "For example, your response should look like this: {''score': 4.8}.",
                      },
                  ],
              )
              # Convert response to a Python dictionary.
              response_message = completion["choices"][0]["message"][
                  "content"
              ]
              response_dict = ast.literal_eval(response_message)
              result_qa_pair = [response_dict, qa_set]
  
              print(key, "done")
  
              # Save the question-answer pairs to a json file.
              with open(f"{output_dir}/{key}.json", "w") as f:
                  json.dump(result_qa_pair, f, indent=4)
  
          except Exception as e:
              print(f"Error processing file '{key}': {e}")
  
file_path: llama-vid/llamavid/eval/evaluate_benchmark_4_temporal.py
imports: import openai
  import os
  import argparse
  import json
  import ast
  from multiprocessing.pool import Pool
label_desc: Use image node_id 2 for calling a global function with example usage: annotate(prediction_set, caption_files, output_dir) without return types