code: def _check_format_string(text, kwargs):
      """Check if string can be exactly formatted with kwargs
  
      This is necessary because even though calling .format(...) on a string will
      raise if a key is missing, it ignores extra keys, and we want to error in
      this case.
  
      Gives a warning if the text contains placeholders that are not in kwargs, or
      if kwargs contains keys that are not in the text.
  
      Parameters
      ----------
      text : str
        The string to format.
  
      kwargs : dict
        The values to use for formatting.
  
      """
      formatter = Formatter()
      keys = {
          key
          for _, key, _, _ in formatter.parse(text)
          if key is not None
      }
      keys_expected = set(kwargs.keys())
      num_keys = len(keys_expected)
  
      if keys == keys_expected:
          return
  
      keys_missing = keys_expected - keys
      keys_extra = keys - keys_expected
      msg = (
          f"The prompt may not be correct, it expects {num_keys} "
          "placeholders: "
          + ", ".join(f"'{key}'" for key in sorted(keys_expected))
      )
      if keys_missing:
          msg += ", missing keys: "
          msg += ", ".join(f"'{key}'" for key in sorted(keys_missing))
      if keys_extra:
          msg += ", extra keys: "
          msg += ", ".join(f"'{key}'" for key in sorted(keys_extra))
      warnings.warn(msg)
  
imports: import importlib
  import warnings
  from string import Formatter
  import numpy
  import torch
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.utils import check_random_state
  from sklearn.utils.validation import check_is_fitted
  from transformers import AutoConfig, AutoTokenizer, LogitsProcessor
  from skorch.exceptions import LowProbabilityError
  from skorch.llm.prompts import DEFAULT_PROMPT_FEW_SHOT, DEFAULT_PROMPT_ZERO_SHOT, DELIM
label_desc: Use image node_id 1 for calling a global function with example usage: _check_format_string(text, kwargs) without return types