code: def test_nested_traces():
      @scope
      def f1():
          return pyro.sample("x", dist.Bernoulli(0.5))
  
      @scope
      def f2():
          f1()
          f1()
          f1()
          return pyro.sample("y", dist.Bernoulli(0.5))
  
      expected_names = ["f2/f1/x", "f2/f1__1/x", "f2/f1__2/x", "f2/y"]
      tr2 = poutine.trace(name_count(name_count(f2))).get_trace()
      actual_names = [
          name
          for name, node in tr2.nodes.items()
          if node["type"] == "sample"
      ]
      assert expected_names == actual_names
  
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 7 for calling a global function with example usage: test_nested_traces() and returns: pyro, pyro