code: def collate(results_dir):
      """
      Collate the results of running GAIA
  
      Args:
          results_dir (path): The folder were results were be saved.
      """
  
      all_results = list()
      max_instances = 0
  
      for test_id in os.listdir(results_dir):
          test_path = os.path.join(results_dir, test_id)
  
          # Collect the results vector
          results = [test_id]
  
          instance = 0
          instance_dir = os.path.join(test_path, str(instance))
          while os.path.isdir(instance_dir):
              expected_answer_file = os.path.join(
                  instance_dir, "expected_answer.txt"
              )
              if not os.path.isfile(expected_answer_file):
                  # Expected answer is missing
                  results.append("")
  
                  instance += 1
                  instance_dir = os.path.join(test_path, str(instance))
                  continue
  
              expected_answer = "!!!NULL ANSWER!!!"
              with open(expected_answer_file, "rt") as fh:
                  expected_answer = fh.read().strip()
  
              console_log_file = os.path.join(
                  instance_dir, "console_log.txt"
              )
              if not os.path.isfile(console_log_file):
                  # Console log file missing
                  results.append("")
  
                  instance += 1
                  instance_dir = os.path.join(test_path, str(instance))
                  continue
  
              with open(console_log_file, "rt") as fh:
                  console_log = fh.read()
  
                  final_answer = ""
                  m = re.search(
                      r"FINAL ANSWER:(.*?)\n", console_log, re.DOTALL
                  )
                  if m:
                      final_answer = m.group(1).strip()
  
                  # print(f"Expected Answer: {expected_answer}\nAutogen Answer: {final_answer}\n")
  
                  if normalize_answer(
                      expected_answer
                  ) == normalize_answer(final_answer):
                      results.append("1")
                  else:
                      results.append("-1")
  
              instance += 1
              instance_dir = os.path.join(test_path, str(instance))
  
          max_instances = max(max_instances, instance)
  
          # Buffer the results
          all_results.append(results)
  
      # Create a header
      header = "TestId"
      for i in range(0, max_instances):
          header += ",Trial" + str(i)
      print(header)
  
      # Print a fully-populated table of results
      for r in all_results:
          while len(r) < max_instances + 1:
              r.append("")
          print(",".join(r))
  
imports: import os
  import json
  import re
  import sys
  import argparse
label_desc: Use image node_id 2 for calling a global function with example usage: collate(results_dir) without return types