code: def do_elbo_test(
      self,
      reparameterized,
      n_steps,
      lr,
      prec,
      beta1,
      difficulty=1.0,
      model_permutation=False,
  ):
      n_repa_nodes = (
          torch.sum(self.which_nodes_reparam)
          if not reparameterized
          else len(self.q_topo_sort)
      )
      logger.info(
          (
              " - - - DO GAUSSIAN %d-LAYERED PYRAMID ELBO TEST "
              + "(with a total of %d RVs) [reparameterized=%s; %d/%d; perm=%s] - - -"
          )
          % (
              self.N,
              (2**self.N) - 1,
              reparameterized,
              n_repa_nodes,
              len(self.q_topo_sort),
              model_permutation,
          )
      )
      pyro.clear_param_store()
  
      # check graph structure is as expected but only for N=2
      if self.N == 2:
          guide_trace = pyro.poutine.trace(
              self.guide, graph_type="dense"
          ).get_trace(
              reparameterized=reparameterized,
              model_permutation=model_permutation,
              difficulty=difficulty,
          )
          expected_nodes = set(
              [
                  "log_sig_1R",
                  "kappa_1_1L",
                  "_INPUT",
                  "constant_term_loc_latent_1R",
                  "_RETURN",
                  "loc_latent_1R",
                  "loc_latent_1",
                  "constant_term_loc_latent_1",
                  "loc_latent_1L",
                  "constant_term_loc_latent_1L",
                  "log_sig_1L",
                  "kappa_1_1R",
                  "kappa_1R_1L",
                  "log_sig_1",
              ]
          )
          expected_edges = set(
              [
                  ("loc_latent_1R", "loc_latent_1"),
                  ("loc_latent_1L", "loc_latent_1R"),
                  ("loc_latent_1L", "loc_latent_1"),
              ]
          )
          assert expected_nodes == set(guide_trace.nodes)
          assert expected_edges == set(guide_trace.edges)
  
      adam = optim.Adam({"lr": lr, "betas": (beta1, 0.999)})
      svi = SVI(self.model, self.guide, adam, loss=TraceGraph_ELBO())
  
      for step in range(n_steps):
          t0 = time.time()
          svi.step(
              reparameterized=reparameterized,
              model_permutation=model_permutation,
              difficulty=difficulty,
          )
  
          if step % 5000 == 0 or step == n_steps - 1:
              log_sig_errors = []
              for node in self.target_lambdas:
                  target_log_sig = -0.5 * torch.log(
                      self.target_lambdas[node]
                  )
                  log_sig_error = param_mse(
                      "log_sig_" + node, target_log_sig
                  )
                  log_sig_errors.append(log_sig_error)
              max_log_sig_error = np.max(log_sig_errors)
              min_log_sig_error = np.min(log_sig_errors)
              mean_log_sig_error = np.mean(log_sig_errors)
              leftmost_node = self.q_topo_sort[0]
              leftmost_constant_error = param_mse(
                  "constant_term_" + leftmost_node,
                  self.target_leftmost_constant,
              )
              almost_leftmost_constant_error = param_mse(
                  "constant_term_" + leftmost_node[:-1] + "R",
                  self.target_almost_leftmost_constant,
              )
  
              logger.debug(
                  "[mean function constant errors (partial)]   %.4f  %.4f"
                  % (
                      leftmost_constant_error,
                      almost_leftmost_constant_error,
                  )
              )
              logger.debug(
                  "[min/mean/max log(scale) errors]   %.4f  %.4f   %.4f"
                  % (
                      min_log_sig_error,
                      mean_log_sig_error,
                      max_log_sig_error,
                  )
              )
              logger.debug(
                  "[step time = %.3f;  N = %d;  step = %d]\n"
                  % (time.time() - t0, self.N, step)
              )
  
      assert_equal(0.0, max_log_sig_error, prec=prec)
      assert_equal(0.0, leftmost_constant_error, prec=prec)
      assert_equal(0.0, almost_leftmost_constant_error, prec=prec)
  
imports: import logging
  import os
  import time
  from unittest import TestCase
  import numpy
  import pytest
  import torch
  import pyro
  import pyro.distributions
  import pyro.optim
  from pyro.distributions.testing import fakes
  from pyro.infer import SVI, TraceGraph_ELBO
  from pyro.poutine import Trace
  from tests.common import assert_equal
label_desc: Use image node_id 15 for calling the GaussianPyramidTests obj's underlying member method code with example usage: obj.do_elbo_test(reparameterized, n_steps, lr, prec, beta1, difficulty, model_permutation) without return types