def METHOD_NAME():
    class Linear(Parameterized):
        def __init__(self, a):
            super().__init__()
            self.a = Parameter(a)
        def forward(self, x):
            return self.a * x
    target_a = torch.tensor(2.0)
    x_train = torch.rand(100)
    y_train = target_a * x_train + torch.rand(100) * 0.001
    linear = Linear(torch.tensor(1.0))
    linear.a = PyroSample(dist.Normal(0, 10))
    linear.autoguide("a", dist.Normal)
    def model(x, y):
        linear.set_mode("model")
        mu = linear(x)
        with pyro.plate("plate"):
            return pyro.sample("y", dist.Normal(mu, 0.1), obs=y)
    def guide(x, y):
        linear.set_mode("guide")
        linear._load_pyro_samples()
    loss_fn = pyro.infer.Trace_ELBO().differentiable_loss
    optimizer = torch.optim.Adam(linear.parameters(), lr=0.5)
    def closure():
        optimizer.zero_grad()
        loss = loss_fn(model, guide, x_train, y_train)
        loss.backward()
        return loss
    for i in range(200):
        optimizer.step(closure)
    linear.mode = "guide"
    assert_equal(linear.a, target_a, prec=0.05)