class_docstr: An `Adapter`, guided by the `AdapterSpec`, takes a `Scenario` and produces
  a `ScenarioState`. It has additional logic surrounding in-context examples.
docstr: Returns a single example of the prompt. `include_output` controls whether the gold output is included.
docstr_tok: ["Returns","a","single","example","of","the","prompt",".","`","include_output","`","controls","whether","the","gold","output","is","included","."]
code: def construct_example_prompt(
      self,
      instance: Instance,
      include_output: bool,
      reference_index: Optional[int],
  ) -> str:
      """
      Returns a single example of the prompt. `include_output` controls whether the gold output is included.
      """
      # Input
      result: str = (
          self.adapter_spec.input_prefix
          + (instance.input.text or "")
          + self.adapter_spec.input_suffix
      )
  
      # References (optionally) and output
      output: str
  
      delimiter = ","
      if reference_index is None:
          # Put only the correct reference as the output
          correct_references: List[
              Reference
          ] = instance.all_correct_references
          if not correct_references:
              output = "n/a"
          else:
              output = delimiter.join(
                  [
                      correct_reference.output.text
                      for correct_reference in correct_references
                  ]
              )
      else:
          reference = instance.references[reference_index]
          output = reference.output.text
  
      if include_output:
          result += (
              self.adapter_spec.output_prefix
              + output
              + self.adapter_spec.output_suffix
          )
      else:
          result += self.adapter_spec.output_prefix.rstrip()
  
      return result
  
imports: import random
  from abc import ABC
  from collections import defaultdict
  from dataclasses import replace
  from itertools import cycle
  from typing import List, Dict, Optional
  from helm.benchmark.adaptation.prompt import Prompt
  from helm.benchmark.adaptation.request_state import RequestState
  from helm.benchmark.adaptation.scenario_state import ScenarioState
  from helm.benchmark.scenarios.scenario import Instance, TRAIN_SPLIT, EVAL_SPLITS, Reference
  from helm.common.general import parallel_map
  from helm.common.hierarchical_logger import hlog, htrack, htrack_block
  from .adapter import Adapter
label_desc: Use image node_id 5 for calling the InContextLearningAdapter obj's underlying member method code with example usage: obj.construct_example_prompt(instance, include_output, reference_index) and returns: result