code: def save_gpt_evaluation_statistics(
      model_name: str, evaluations: List[Dict], save_path: str
  ) -> None:
      """
      Generate statistics for one model.
  
      Args:
          model_name: name of the model for saving statistics.
          evaluations: evaluations for all of the model answers.
          save_path: path to save GPT evaluation statistics.
      """
  
      if not os.path.exists(save_path):
          os.makedirs(save_path)
  
      data_per_category = {}
      for evaluation in evaluations:
          category = evaluation["category"]
          if evaluation["category"] in data_per_category.keys():
              data_per_category[category].append(evaluation)
          else:
              data_per_category[category] = [evaluation]
  
      all_statistics = {}
      for category, data in data_per_category.items():
          metrics = data[0]["evaluation"].keys()
          scores = {metric: [] for metric in metrics}
          for evaluation in data:
              for metric in metrics:
                  if evaluation["evaluation"][metric] == {}:
                      # This means after 3 retries, the server still returns an error and we set the score to 0.
                      scores[metric].append(0)
                  elif (
                      evaluation["evaluation"][metric]["logprobs"]
                      is not None
                  ):
                      scores[metric].append(
                          calculate_scores_form_logprobs(
                              evaluation["evaluation"][metric][
                                  "logprobs"
                              ][0]
                          )
                      )
                  else:
                      scores[metric].append(
                          calculate_scores_form_response(
                              evaluation["evaluation"][metric][
                                  "response"
                              ],
                              evaluation,
                          )
                      )
  
          statistics = {}
          for metric in metrics:
              arg_sort = np.argsort(scores[metric])
              statistics[metric] = {}
              statistics[metric]["avg_score"] = sum(
                  scores[metric]
              ) / len(data)
              statistics[metric]["best_3"] = {
                  data[i]["id"]: scores[metric][i]
                  for i in arg_sort[-3:][::-1]
              }
              statistics[metric]["worst_3"] = {
                  data[i]["id"]: scores[metric][i] for i in arg_sort[:3]
              }
  
          all_statistics[category] = statistics
  
      jdump(
          all_statistics,
          os.path.join(
              save_path, f"{model_name}_evaluation_statistics.json"
          ),
      )
  
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 14 for calling a global function with example usage: save_gpt_evaluation_statistics(model_name, evaluations, save_path) without return types