class_docstr: Assign unique names to random variables.
  
  1. For a new varialbe use its declared name if given, otherwise use the distribution name::
  
      sample("x", dist.Bernoulli ... )  # -> x
      sample(dist.Bernoulli ... )  # -> Bernoulli
  
  2. For repeated variables names append the counter as a suffix::
  
      sample(dist.Bernoulli ... )  # -> Bernoulli
      sample(dist.Bernoulli ... )  # -> Bernoulli1
      sample(dist.Bernoulli ... )  # -> Bernoulli2
  
  3. Functions and iterators can be used as a name scope::
  
      @autoname
      def f1():
          sample(dist.Bernoulli ... )
  
      @autoname
      def f2():
          f1()  # -> f2/f1/Bernoulli
          f1()  # -> f2/f1__1/Bernoulli
          sample(dist.Bernoulli ... )  # -> f2/Bernoulli
  
      @autoname(name="model")
      def f3():
          for i in autoname(range(3), name="time"):
              # model/time/Bernoulli .. model/time__1/Bernoulli .. model/time__2/Bernoulli
              sample(dist.Bernoulli ... )
              # model/time/f1/Bernoulli .. model/time__1/f1/Bernoulli .. model/time__2/f1/Bernoulli
              f1()
  
  4. Or scopes can be added using the with statement::
  
      def f4():
          with autoname(name="prefix"):
              f1()  # -> prefix/f1/Bernoulli
              f1()  # -> prefix/f1__1/Bernoulli
              sample(dist.Bernoulli ... )  # -> prefix/Bernoulli
code: def _pyro_genname(msg):
      raw_name = msg["fn"](*msg["args"])
      fresh_name = _SCOPE_STACK.fresh_name(raw_name)
  
      msg["value"] = str(_SCOPE_STACK) + "/" + fresh_name
      msg["stop"] = True
  
imports: from collections import defaultdict
  from collections.abc import Iterable
  from functools import singledispatch
  import pyro
  from pyro.poutine.handlers import _make_handler
  from pyro.poutine.reentrant_messenger import ReentrantMessenger
  from pyro.poutine.runtime import effectful
label_desc: Use image node_id 6 for calling the AutonameMessenger obj's underlying member method code with example usage: obj._pyro_genname(msg) without return types