class_docstr: Metaclass for :class:`Op` classes.
  
  This weakly caches op instances. Caching strategy is to key on
  ``args[arity:],kwargs`` and to weakly retain values. Caching requires all
  non-funsor args to be hashable; for non-hashable args, implement a derived
  metaclass with custom :meth:`hash_args_kwargs` method.
code: def __init__(cls, *args, **kwargs):
      super().__init__(*args, **kwargs)
      cls._instance_cache = weakref.WeakValueDictionary()
      cls._subclass_registry = []
  
      # Register all existing patterns.
      for supercls in reversed(inspect.getmro(cls)):
          for pattern, fn in getattr(
              supercls, "_subclass_registry", ()
          ):
              cls.dispatcher.add(pattern, WeakPartial(fn, cls))
  
imports: import contextlib
  import functools
  import inspect
  import weakref
  from collections import OrderedDict
  from funsor.registry import PartialDispatcher
  from funsor.util import methodof
label_desc: Use image node_id 1 to create a new OpMeta object from inherited base classes: type with example: obj = OpMeta(cls)