code: def do_test_auto(self, N, reparameterized, n_steps):
      logger.debug("\nGoing to do AutoGaussianChain test...")
      pyro.clear_param_store()
      self.setUp()
      self.setup_chain(N)
      self.compute_target(N)
      self.guide = AutoMultivariateNormal(self.model)
      logger.debug(
          "target auto_loc: {}".format(
              self.target_auto_mus[1:].detach().cpu().numpy()
          )
      )
      logger.debug(
          "target auto_diag_cov: {}".format(
              self.target_auto_diag_cov[1:].detach().cpu().numpy()
          )
      )
  
      # TODO speed up with parallel num_particles > 1
      adam = optim.Adam({"lr": 0.01, "betas": (0.95, 0.999)})
      elbo = Trace_ELBO(num_particles=100, vectorize_particles=True)
      svi = SVI(self.model, self.guide, adam, elbo)
  
      for k in range(n_steps):
          loss = svi.step(reparameterized)
          assert np.isfinite(loss), loss
  
          if k % 100 == 0 and k > 0 or k == n_steps - 1:
              logger.debug(
                  "[step {}] guide mean parameter: {}".format(
                      k, self.guide.loc.detach().cpu().numpy()
                  )
              )
              L = self.guide.scale_tril * self.guide.scale[:, None]
              diag_cov = torch.mm(L, L.t()).diag()
              logger.debug(
                  "[step {}] auto_diag_cov: {}".format(
                      k, diag_cov.detach().cpu().numpy()
                  )
              )
  
      assert_equal(
          self.guide.loc.detach(),
          self.target_auto_mus[1:],
          prec=0.05,
          msg="guide mean off",
      )
      assert_equal(
          diag_cov,
          self.target_auto_diag_cov[1:],
          prec=0.07,
          msg="guide covariance off",
      )
  
imports: import logging
  from functools import partial
  import numpy
  import pytest
  import torch
  from torch.distributions import biject_to, constraints
  import pyro
  import pyro.distributions
  import pyro.optim
  from pyro.distributions.transforms import block_autoregressive, iterated
  from pyro.infer import SVI, Trace_ELBO, TraceMeanField_ELBO
  from pyro.infer.autoguide import AutoDiagonalNormal, AutoIAFNormal, AutoLaplaceApproximation, AutoLowRankMultivariateNormal, AutoMultivariateNormal
  from pyro.infer.autoguide.guides import AutoNormalizingFlow
  from tests.common import assert_equal
  from tests.integration_tests.test_conjugate_gaussian_models import GaussianChain
label_desc: Use image node_id 3 for calling the AutoGaussianChain obj's underlying member method code with example usage: obj.do_test_auto(N, reparameterized, n_steps) without return types