class_docstr: ``ScopeMessenger`` is the implementation of :func:`pyro.contrib.autoname.scope`
class_docstr_tok: ["``","ScopeMessenger","``","is","the","implementation","of",":","func",":","`","pyro.contrib.autoname.scope","`"]
code: def __enter__(self):
      if self.prefix is None:
          raise ValueError("no prefix was provided")
      if not self.inner:
          # to accomplish adding a counter to duplicate scopes,
          # we make ScopeMessenger.__enter__ effectful
          # so that the same mechanism that adds counters to sample names
          # can be used to add a counter to a scope name
          self.prefix = self._collect_scope(self.prefix)
      return super().__enter__()
  
imports: import functools
  from pyro.poutine.messenger import Messenger
  from pyro.poutine.runtime import effectful
label_desc: Use image node_id 3 for calling the ScopeMessenger obj's underlying member method code with example usage: obj.__enter__() and returns: super