code: def _key_from_dict(d) -> Hashable:
      """Convert nested dict into a frozen, hashable structure usable as a key."""
      if isinstance(d, dict):
          return frozenset((k, _key_from_dict(v)) for k, v in d.items())
      elif isinstance(d, (list, tuple)):
          return tuple(map(_key_from_dict, d))
      else:
          return d
  
imports: from collections.abc import Hashable, Sequence
  import threading
  from typing import Optional
  from absl import logging
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.lib import caching
label_desc: Use image node_id 1 for calling a global function with example usage: _key_from_dict(d) and returns: frozenset, tuple, d