code: def to_bool(val):
      """
      Convert "boolean" strings (e.g., from env. vars.) to real booleans.
  
      Values mapping to :code:`True`:
  
      - :code:`True`
      - :code:`"true"` / :code:`"t"`
      - :code:`"yes"` / :code:`"y"`
      - :code:`"on"`
      - :code:`"1"`
      - :code:`1`
  
      Values mapping to :code:`False`:
  
      - :code:`False`
      - :code:`"false"` / :code:`"f"`
      - :code:`"no"` / :code:`"n"`
      - :code:`"off"`
      - :code:`"0"`
      - :code:`0`
  
      :raises ValueError: for any other value.
  
      .. versionadded:: 21.3.0
      """
      if isinstance(val, str):
          val = val.lower()
      truthy = {True, "true", "t", "yes", "y", "on", "1", 1}
      falsy = {False, "false", "f", "no", "n", "off", "0", 0}
      try:
          if val in truthy:
              return True
          if val in falsy:
              return False
      except TypeError:
          # Raised when "val" is not hashable (e.g., lists)
          pass
      msg = f"Cannot convert value to bool: {val}"
      raise ValueError(msg)
  
imports: import typing
  from ._compat import _AnnotationExtractor
  from ._make import NOTHING, Factory, pipe
label_desc: Use image node_id 3 for calling a global function with example usage: to_bool(val) and returns: True, False