code: def _validate_prompt_template(
      template_fields: Set[str],
      task: Optional[str],
      is_few_shot: bool,
      columns: List[str],
      input_col_name: str,
  ):
      """Validates that the template contains the necessary fields for the prompt."""
      if is_few_shot and CONTEXT not in template_fields:
          raise ValueError(
              f"Prompt template must contain the '{CONTEXT}' field for few-shot learning"
          )
  
      if task is not None and TASK not in template_fields:
          raise ValueError(
              f"Prompt template must contain the '{TASK}' field if a task is provided"
          )
  
      if SAMPLE in template_fields:
          if input_col_name not in columns:
              raise ValueError(
                  f"Prompt template contains the '{SAMPLE}' field, "
                  f"but the input column '{input_col_name}' is not in the dataset"
              )
      elif not any(col in template_fields for col in columns):
          raise ValueError(
              f"Prompt template must contain either the '{SAMPLE}' field or one of the columns from the dataset"
          )
  
file_path: ludwig/ludwig/data/prompt.py
imports: import json
  import logging
  import os
  import string
  from typing import Any, Dict, List, Optional, Set, Tuple, Type, TYPE_CHECKING
  import pandas
  from ludwig.models.retrieval import df_checksum, get_retrieval_model, RetrievalModel
  from ludwig.utils.fs_utils import get_default_cache_location, makedirs, path_exists
  from ludwig.utils.types import DataFrame, Series
label_desc: Use image node_id 3 for calling a global function with example usage: _validate_prompt_template(template_fields, task, is_few_shot, columns, input_col_name) without return types