code: def classify(
      mg: ModelGradedSpec,
      completion_fn: CompletionFn,
      completion_kwargs: Optional[dict[str, Any]] = None,
      format_kwargs: Optional[dict[str, Any]] = None,
      eval_type: Optional[str] = None,
      n: Optional[int] = None,
      match_fn: Optional[str] = None,
  ) -> str:
      completion_kwargs = completion_kwargs or {}
      format_kwargs = format_kwargs or {}
      match_fn = match_fn or "starts_or_endswith"
  
      # get choice strings
      choice_strings = get_choice_strings(mg.choice_strings, n=n)
  
      # append answer prompt
      prompt = mg.prompt
      if isinstance(prompt, str):
          prompt = [{"role": "user", "content": prompt}]
      if eval_type:
          prompt = append_answer_prompt(
              prompt=prompt,
              eval_type=eval_type,
              choice_strings=choice_strings,
          )
  
      evaluate = PromptFn(
          prompt, completion_fn=completion_fn, **completion_kwargs
      )
      evaluation, prompt = evaluate(n=n, **format_kwargs)
      choice = get_choice(
          evaluation,
          mg.eval_type or eval_type,
          match_fn,
          choice_strings,
      )
      score = get_choice_score(choice, choice_strings, mg.choice_scores)
      return choice, dict(
          score=score,
          sampled=[evaluation],
          prompt=prompt,
          invalid_choice=choice == INVALID_STR,
      )
  
file_path: evals/evals/elsuite/modelgraded/classify_utils.py
imports: import logging
  import string
  from typing import Any, Callable, Iterable, Optional, Union
  from evals import CompletionFn
  from evals.elsuite.modelgraded.base import ModelGradedSpec
  from evals.elsuite.utils import PromptFn, format_necessary, format_prompt
  from evals.prompt.base import OpenAICreateChatPrompt, is_chat_prompt
label_desc: Use image node_id 2 for calling a global function with example usage: classify(mg, completion_fn, completion_kwargs, format_kwargs, eval_type, n, match_fn) and returns: choice,  dict