code: def get_batch_prompt(
      conv: Conversation,
      batch: List[Dict],
      few_shot_data: List[str],
      tokenizer: Optional[AutoTokenizer],
      language: Optional[str],
      model_max_length: Optional[int],
  ) -> Tuple[List[Dict], List[Dict]]:
      """
      Get batch prompt and target.
  
      Args:
          conv: Conversation template.
          batch: Batch data to generate prompt from.
          few_shot_data: Few shot data to generate few shot prompt prefix.
  
      Returns:
          Tuple containg batch prompt and target.
  
      """
  
      batch_prompt = []
      batch_target = []
  
      if isinstance(batch[0], dict):
          for b in batch:
              few_shot_prefix = ""
              if few_shot_data is not None:
                  assert not isinstance(b["instruction"], list), print(
                      f"When performing few-shot, {b['dataset']} shouldn't be a multiturn dataset."
                  )
                  # For few-shot, only need input. Otherwise use instruction (in AGIEval).
                  query_text = (
                      b["input"]
                      if b.get("input", "") != ""
                      else b["instruction"]
                  )
  
                  if isinstance(b["target"], str):
                      zero_shot_prompt = query_text + b["target"]
                      max_tokens = model_max_length - len(
                          tokenizer([zero_shot_prompt]).input_ids[0]
                      )
                  else:
                      raise Exception(
                          "When using few-shot, target answer should be a string."
                      )
  
                  few_shot_prefix = get_few_shot_prefix(
                      conv,
                      few_shot_data,
                      tokenizer,
                      language,
                      max_tokens,
                  )
  
                  conv.append_message(
                      conv.roles[0], few_shot_prefix + query_text
                  )
                  conv.append_message(conv.roles[1], None)
              else:
                  if not isinstance(b["instruction"], list):
                      if b["instruction"] != "":
                          query_text = (
                              b["instruction"] + "\n\n" + b["input"]
                              if b["input"] != ""
                              else b["instruction"]
                          )
                      else:
                          query_text = b["input"]
                      conv.append_message(conv.roles[0], query_text)
                      conv.append_message(conv.roles[1], None)
                  else:
                      assert (
                          len(b["instruction"]) >= len(b["output"]) + 1
                      )
                      cur_turns = len(b["output"])
                      for turn in range(cur_turns):
                          conv.append_message(
                              conv.roles[0], b["instruction"][turn]
                          )
                          conv.append_message(
                              conv.roles[1], b["output"][turn]
                          )
                      conv.append_message(
                          conv.roles[0], b["instruction"][cur_turns]
                      )
                      conv.append_message(conv.roles[1], None)
  
              batch_prompt.append(conv.get_prompt())
  
              target = b["target"]
              if isinstance(b["target"], str):
                  target = [target]
  
              batch_target.append(target)
  
              conv.clear()
  
      return batch_prompt, batch_target
  
file_path: colossalai/applications/ColossalEval/colossal_eval/utils/conversation.py
imports: import dataclasses
  from enum import Enum, auto
  from typing import Dict, List, Optional, Tuple
  from transformers import AutoTokenizer
label_desc: Use image node_id 2 for calling a global function with example usage: get_batch_prompt(conv, batch, few_shot_data, tokenizer, language, model_max_length) and returns: batch_prompt,  batch_target