code: def _find_impl(cls, registry):
      """Returns the best matching implementation from *registry* for type *cls*.
  
      Where there is no registered implementation for a specific type, its method
      resolution order is used to find a more generic implementation.
  
      Note: if *registry* does not contain an implementation for the base
      *object* type, this function may return None.
  
      """
      mro = _compose_mro(cls, registry.keys())
      match = None
      for t in mro:
          if match is not None:
              # If *match* is an implicit ABC but there is another unrelated,
              # equally matching implicit ABC, refuse the temptation to guess.
              if (
                  t in registry
                  and t not in cls.__mro__
                  and match not in cls.__mro__
                  and not issubclass(match, t)
              ):
                  raise RuntimeError(
                      "Ambiguous dispatch: {} or {}".format(match, t)
                  )
              break
          if t in registry:
              match = t
      return registry.get(match)
  
imports: from abc import get_cache_token
  from collections import namedtuple
  from reprlib import recursive_repr
  from _thread import RLock
label_desc: Use image node_id 26 for calling a global function with example usage: _find_impl(cls, registry) and returns: registry