code: def check_getitem(mapping, /, **kwargs):
      """
      *kwargs* must consist of a single *key, value* pair.  If *key* is in
      *mapping*, return ``mapping[value]``; else, raise an appropriate
      ValueError.
  
      Examples
      --------
      >>> _api.check_getitem({"foo": "bar"}, arg=arg)
      """
      if len(kwargs) != 1:
          raise ValueError(
              "check_getitem takes a single keyword argument"
          )
      ((k, v),) = kwargs.items()
      try:
          return mapping[v]
      except KeyError:
          raise ValueError(
              f"{v!r} is not a valid value for {k}; supported values are "
              f"{', '.join(map(repr, mapping))}"
          ) from None
  
imports: import functools
  import itertools
  import re
  import sys
  import warnings
  from .deprecation import deprecated, warn_deprecated, rename_parameter, delete_parameter, make_keyword_only, deprecate_method_override, deprecate_privatize_attribute, suppress_matplotlib_deprecation_warning, MatplotlibDeprecationWarning
label_desc: Use image node_id 4 for calling a global function with example usage: check_getitem() and returns: mapping