code: def multiturn_chat_completion(
      user_messages: List[str], model: str, max_tokens: int = 1, turns=2
  ) -> Dict[str, Any]:
      """
      Do multi-turn chat completion.
  
      When turns == 1, it is a one-turn conversation for normal GPT evaluation.
      When turns == 2, it is a two-turn conversation which is used for GPT evaluation with reference answers.
  
      Args:
          user_messages: messages user wants to send.
          model: the model used to evaluate answers.
          max_tokens: the maximum number of tokens to generate in the chat completion.
          turns: the number of turns for conversation.
  
      Returns:
          Last turn's response.
      """
  
      if len(user_messages) != turns:
          raise Exception(
              "The length of user messages should be equal to the turn number!"
          )
  
      assistant_responses = []
  
      for i in range(turns):
          messages_to_send = []
  
          for j in range(i):
              messages_to_send.append(
                  fill_in_message("user", user_messages[j])
              )
              messages_to_send.append(
                  fill_in_message(
                      "assistant",
                      assistant_responses[j]["choices"][0]["message"][
                          "content"
                      ],
                  )
              )
  
          # Length of user messages == Length of assistant messages + 1
          # Because we always expect the api to response
          messages_to_send.append(
              fill_in_message("user", user_messages[i])
          )
  
          response = openai.ChatCompletion.create(
              model=model,
              messages=messages_to_send,
              temperature=0,
              max_tokens=max_tokens,
          )
  
          # Avoid exceeding rate limits.
          # You can comment this line if your request doesn't contain many tokens.
          time.sleep(1)
  
          assistant_responses.append(response)
  
      return assistant_responses[-1]
  
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 7 for calling a global function with example usage: multiturn_chat_completion(user_messages, model, max_tokens, turns) and returns: assistant_responses