code: def test_recur_multi():
      @scope(inner=True)
      def model1(r=True):
          model2()
          with scope(prefix="inter"):
              model2()
              if r:
                  model1(r=False)
          model2()
  
      @scope(inner=True)
      def model2():
          return pyro.sample("y", dist.Normal(0.0, 1.0))
  
      true_samples = [
          "model1/model2/y",
          "model1/inter/model2/y",
          "model1/inter/model1/model2/y",
          "model1/inter/model1/inter/model2/y",
          "model1/inter/model1/model2/y__1",
          "model1/model2/y__1",
      ]
  
      tr = poutine.trace(name_count(model1)).get_trace()
  
      samples = [
          name
          for name, node in tr.nodes.items()
          if node["type"] == "sample"
      ]
      logger.debug(samples)
      assert true_samples == samples
  
file_path: pyro/tests/contrib/autoname/test_scoping.py
imports: import logging
  import torch
  import pyro
  import pyro.distributions.torch
  import pyro.poutine
  from pyro.contrib.autoname import name_count, scope
label_desc: Use image node_id 2 for calling a global function with example usage: test_recur_multi() and returns: pyro