class_docstr: Base effect handler class for the :func:`~pyro.contrib.funsor.to_funsor`
  and :func:`~pyro.contrib.funsor.to_data` primitives.
  Any effect handlers that invoke these primitives internally or wrap
  code that does should inherit from :class:`~NamedMessenger`.
  
  This design ensures that the global name-dim mapping is reset upon handler exit
  rather than potentially persisting until the entire program terminates.
code: def __init__(self, first_available_dim=None):
      assert (
          first_available_dim is None or first_available_dim < 0
      ), first_available_dim
      self.first_available_dim = first_available_dim
      self._saved_dims = set()
      return super().__init__()
  
imports: from collections import OrderedDict
  from contextlib import ExitStack
  from pyro.contrib.funsor.handlers.runtime import _DIM_STACK, DimRequest, DimType, StackFrame
  from pyro.poutine.reentrant_messenger import ReentrantMessenger
label_desc: Use image node_id 1 to create a new NamedMessenger object from inherited base classes: ReentrantMessenger with example: obj = NamedMessenger(first_available_dim)