code: def save_battle_results(
      evaluations: List[Dict], name1: str, name2: str, save_path: str
  ) -> None:
      """
      Save evaluation results (model 1 vs model 2) from GPT-4.
  
      Args:
          evaluations: evaluation results from GPT-4.
          name1: model 1 's name.
          name2: model 2 's name.
          save_path: path to save battle results.
      """
  
      evaluation_file = deepcopy(evaluations)
  
      ans1_score = 0
      ans2_score = 0
      better_count = 0
      worse_count = 0
      tie_count = 0
      invalid_count = 0
  
      better_file = []
      worse_file = []
      tie_file = []
      invalid_file = []
  
      for idx, evaluation in enumerate(evaluations):
          scores = parse_battle_score(evaluation["evaluation"])
          evaluation_file[idx]["score"] = scores
  
          if scores[0] == -1 and scores[1] == -1:
              invalid_count += 1
              invalid_file.append(evaluation_file[idx])
              print(
                  f'Invalid score pair: {evaluation_file[idx]["id"]}.'
              )
          else:
              if scores[0] > scores[1]:
                  worse_count += 1
                  worse_file.append(evaluation_file[idx])
              elif scores[0] < scores[1]:
                  better_count += 1
                  better_file.append(evaluation_file[idx])
              else:
                  tie_count += 1
                  tie_file.append(evaluation_file[idx])
              ans1_score += scores[0]
              ans2_score += scores[1]
  
      prefix = f"{name1}_vs_{name2}"
  
      if not os.path.exists(save_path):
          os.makedirs(save_path)
  
      jdump(
          better_file,
          os.path.join(save_path, prefix, f"{name2}_better.json"),
      )
      jdump(
          worse_file,
          os.path.join(save_path, prefix, f"{name2}_worse.json"),
      )
      jdump(
          tie_file,
          os.path.join(save_path, prefix, f"{prefix}_tie.json"),
      )
      jdump(
          invalid_file,
          os.path.join(save_path, prefix, f"{prefix}_invalid.json"),
      )
      jdump(
          evaluation_file,
          os.path.join(save_path, prefix, f"{prefix}_evaluations.json"),
      )
  
      if os.path.exists(os.path.join(save_path, "battle_results.json")):
          results = jload(
              os.path.join(save_path, "battle_results.json")
          )
      else:
          results = {}
  
      results[prefix] = {
          "model": [name1, name2],
          "better": better_count,
          "worse": worse_count,
          "tie": tie_count,
          "win_rate": better_count / (len(evaluations) - invalid_count),
          "score": [
              ans1_score / (len(evaluations) - invalid_count),
              ans2_score / (len(evaluations) - invalid_count),
          ],
      }
      jdump(results, os.path.join(save_path, "battle_results.json"))
  
      print(f"Total {invalid_count} invalid score pair(s).")
      print(f"Model {name2} has {better_count} better answer(s).")
      print(f"Model {name2} has {worse_count} worse answer(s).")
      print(f"{tie_count} answer(s) play(s) to a tie.")
      print(
          f"Win rate of model {name2}: {better_count/(len(evaluations)-invalid_count):.2f}"
      )
      print(
          f"Model {name1} average score: {ans1_score/(len(evaluations)-invalid_count):.2f}"
      )
      print(
          f"Model {name2} average score: {ans2_score/(len(evaluations)-invalid_count):.2f}"
      )
  
imports: import concurrent.futures
  import os
  import re
  import time
  from copy import deepcopy
  from typing import Any, Dict, List
  import matplotlib.pyplot
  import numpy
  import openai
  import pandas
  import seaborn
  import tqdm
  from colossal_eval.utils import jdump, jload
label_desc: Use image node_id 4 for calling a global function with example usage: save_battle_results(evaluations, name1, name2, save_path) without return types