code: def get_mtbench_judgements(
      question: Dict[str, Any], prompts: Dict[str, str]
  ):
      id = question["id"]
      judgement = {"id": id, "judgements": [], "ratings": []}
      category = question["category"]
      math = category in NEED_REF_CATS
      turn_number = len(question["instruction"])
  
      for num in range(turn_number):
          assert (len(question["target"]) >= 1 and math) or not math
          kwargs = {}
          if num >= 1:
              prompt = get_mt_prompt(prompts, multiturn=True, math=math)
              if len(question["target"]) >= 1 and math:
                  kwargs = {
                      f"ref_answer_{i+1}": question["target"][i]
                      for i in range(len(question["target"]))
                  }
              user_prompt = prompt["prompt_template"].format(
                  question_1=question["instruction"][0],
                  question_2=question["instruction"][1],
                  answer_1=question["output"][0],
                  answer_2=question["output"][1],
                  **kwargs,
              )
          else:
              prompt = get_mt_prompt(
                  prompts, multiturn=False, math=math
              )
              if len(question["target"]) >= 1 and math:
                  kwargs = {"ref_answer_1": question["target"][0]}
              user_prompt = prompt["prompt_template"].format(
                  question=question["instruction"][0],
                  answer=question["output"][0],
                  **kwargs,
              )
  
          rating = -1
          sys_prompt = prompt["system_prompt"]
          messages = [
              {"role": "system", "content": sys_prompt},
              {"role": "user", "content": user_prompt},
          ]
  
          judgement_str = chat_compeletion_openai(
              messages, temperature=0.0, max_tokens=2048
          )
          match = re.search(one_score_pattern, judgement_str)
          if not match:
              match = re.search(one_score_pattern_backup, judgement_str)
          if match:
              rating = ast.literal_eval(match.groups()[0])
          else:
              rating = -1
  
          judgement["judgements"].append(judgement_str)
          judgement["ratings"].append(rating)
  
      return judgement
  
file_path: ColossalAI/applications/ColossalEval/colossal_eval/evaluate/dataset_evaluator/gpt_judge.py
imports: import ast
  import concurrent.futures
  import copy
  import json
  import os
  import re
  import time
  from typing import Any, Dict, List
  import numpy
  import openai
  import tqdm
label_desc: Use image node_id 4 for calling a global function with example usage: get_mtbench_judgements(question, prompts) and returns: judgement