code: def test_basic_loop():
      @autoname
      def f1():
          return sample(dist.Bernoulli(0.5))
  
      @autoname(name="model")
      def f2():
          f1()
          for i in range(3):
              f1()
              sample("x", dist.Bernoulli(0.5))
          return sample(dist.Normal(0.0, 1.0))
  
      tr = poutine.trace(f2).get_trace()
      assert "model/f1/Bernoulli" in tr.nodes
      assert "model/f1__1/Bernoulli" in tr.nodes
      assert "model/f1__2/Bernoulli" in tr.nodes
      assert "model/f1__3/Bernoulli" in tr.nodes
      assert "model/x" in tr.nodes
      assert "model/x1" in tr.nodes
      assert "model/x2" in tr.nodes
      assert "model/Normal" in tr.nodes
  
file_path: pyro/tests/contrib/autoname/test_autoname.py
imports: import torch
  import pyro
  import pyro.distributions.torch
  import pyro.poutine
  from pyro.contrib.autoname import autoname, sample
label_desc: Use image node_id 4 for calling a global function with example usage: test_basic_loop() and returns: sample, sample