class_docstr: A prompt template.
class_docstr_tok: ["A","prompt","template","."]
docstr: Creates a prompt by applying this template to an example
  
  :param example: the dataset example to create a prompt for
  :param truncate: if True, example fields will be truncated to truncation_length chars
  :param highlight_variables: highlight the added variables
  :return: tuple of 2 strings, for prompt and output
docstr_tok: ["Creates","a","prompt","by","applying","this","template","to","an","example",":","param","example",":","the","dataset","example","to","create","a","prompt","for",":","param","truncate",":","if","True",",","example","fields","will","be","truncated","to","truncation_length","chars",":","param","highlight_variables",":","highlight","the","added","variables",":","return",":","tuple","of","2","strings",",","for","prompt","and","output"]
code: def apply(
      self,
      example,
      truncate=True,
      truncation_length=2048,
      highlight_variables=False,
  ):
      """
      Creates a prompt by applying this template to an example
  
      :param example: the dataset example to create a prompt for
      :param truncate: if True, example fields will be truncated to truncation_length chars
      :param highlight_variables: highlight the added variables
      :return: tuple of 2 strings, for prompt and output
      """
      jinja = self.jinja
  
      # Truncates the prompt if needed
      if truncate:
          trunc_command = f" | string | truncate({truncation_length}) }}}}"  # Escaping curly braces requires doubling them
          jinja = jinja.replace("}}", trunc_command)
  
      # Highlights text that was substituted for variables, if requested
      if highlight_variables:
          jinja = jinja.replace("}}", " | highlight }}")
      rtemplate = env.from_string(jinja)
  
      protected_example = self._escape_pipe(example)
  
      # Adds in answer_choices variable
      if "answer_choices" in protected_example:
          raise ValueError(
              "Example contains the restricted key 'answer_choices'."
          )
  
      protected_example[
          "answer_choices"
      ] = self.get_answer_choices_list(example)
  
      # Renders the Jinja template
      rendered_example = rtemplate.render(**protected_example)
  
      # Splits on the separator, and then replaces back any occurrences of the
      # separator in the original example
      return [
          self._unescape_pipe(part).strip()
          for part in rendered_example.split("|||")
      ]
  
imports: import logging
  import os
  import random
  import re
  import uuid
  from collections import Counter, defaultdict
  from shutil import rmtree
  from typing import Dict, List, Optional, Tuple
  import pandas
  import pkg_resources
  import yaml
  from jinja2 import BaseLoader, Environment, meta
  from ..constants import AUTOMM
label_desc: Use image node_id 9 for calling the Template obj's underlying member method code with example usage: obj.apply(example, truncate, truncation_length, highlight_variables) and returns: unknown