code: def test_init_to_generated():
      def model():
          x = pyro.sample("x", dist.Normal(0, 1))
          y = pyro.sample("y", dist.Normal(0, 1))
          z = pyro.sample("z", dist.Normal(0, 1))
          return x, y, z
  
      class MockGenerate:
          def __init__(self):
              self.counter = 0
  
          def __call__(self):
              values = {
                  "x": torch.tensor(self.counter + 0.0),
                  "y": torch.tensor(self.counter + 0.5),
              }
              self.counter += 1
              return init_to_value(values=values)
  
      mock_generate = MockGenerate()
      with InitMessenger(init_to_generated(generate=mock_generate)):
          for i in range(5):
              x, y, z = model()
              assert x == i
              assert y == i + 0.5
      assert mock_generate.counter == 5
  
imports: import torch
  import pyro
  import pyro.distributions
  from pyro.infer.autoguide.initialization import InitMessenger, init_to_generated, init_to_value
label_desc: Use image node_id 1 for calling a global function with example usage: test_init_to_generated() and returns: x,  y,  z, init_to_value