code: def test_svi_smoke():
      class Model(PyroModule):
          def __init__(self):
              super().__init__()
              self.loc = nn.Parameter(torch.zeros(2))
              self.scale = PyroParam(
                  torch.ones(2), constraint=constraints.positive
              )
              self.z = PyroSample(
                  lambda self: dist.Normal(
                      self.loc, self.scale
                  ).to_event(1)
              )
  
          def forward(self, data):
              loc, log_scale = self.z.unbind(-1)
              with pyro.plate("data"):
                  pyro.sample(
                      "obs", dist.Cauchy(loc, log_scale.exp()), obs=data
                  )
  
      class Guide(PyroModule):
          def __init__(self):
              super().__init__()
              self.loc = nn.Parameter(torch.zeros(2))
              self.scale = PyroParam(
                  torch.ones(2), constraint=constraints.positive
              )
              self.z = PyroSample(
                  lambda self: dist.Normal(
                      self.loc, self.scale
                  ).to_event(1)
              )
  
          def forward(self, *args, **kwargs):
              return self.z
  
      data = torch.randn(5)
      model = Model()
      trace = poutine.trace(model).get_trace(data)
      assert "loc" in trace.nodes.keys()
      assert trace.nodes["loc"]["type"] == "param"
      assert "scale" in trace.nodes
      assert trace.nodes["scale"]["type"] == "param"
  
      guide = Guide()
      trace = poutine.trace(guide).get_trace(data)
      assert "loc" in trace.nodes.keys()
      assert trace.nodes["loc"]["type"] == "param"
      assert "scale" in trace.nodes
      assert trace.nodes["scale"]["type"] == "param"
  
      optim = Adam({"lr": 0.01})
      svi = SVI(model, guide, optim, Trace_ELBO())
      for step in range(3):
          svi.step(data)
  
imports: import io
  import warnings
  import pytest
  import torch
  from torch import nn
  from torch.distributions import constraints, transform_to
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import SVI, Trace_ELBO
  from pyro.nn.module import PyroModule, PyroParam, PyroSample, clear, to_pyro_module_
  from pyro.optim import Adam
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_svi_smoke() and returns: self