code: def testUpdatesCorrectly(self):
      running_variance = sample_stats.RunningVariance.from_shape((3,))
      # This is more straightforward than doing the math, but need at least
      # two observations to get a start.
      pseudo_observations = [-tf.ones(3), tf.ones(3)]
      for pseudo_observation in pseudo_observations:
          running_variance = running_variance.update(pseudo_observation)
  
      results = self._run_hmc(
          num_results=5, initial_running_variance=running_variance
      )
      draws = tf.concat(
          [tf.stack(pseudo_observations), results.draws], axis=0
      )
      self.assertAllClose(
          results.final_precision_factor**2, results.final_precision
      )
      self.assertAllClose(
          results.final_mean, tf.reduce_mean(draws, axis=0)
      )
      self.assertAllClose(
          results.final_precision,
          tf.math.reduce_variance(draws, axis=0),
      )
  
imports: import collections
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_sequential
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import sample
  from tensorflow_probability.python.experimental.mcmc import diagonal_mass_matrix_adaptation
  from tensorflow_probability.python.experimental.mcmc import preconditioned_hmc
  from tensorflow_probability.python.experimental.mcmc import preconditioning_utils
  from tensorflow_probability.python.experimental.stats import sample_stats
  from tensorflow_probability.python.internal import distribute_lib
  from tensorflow_probability.python.internal import distribute_test_lib
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.mcmc import sample
label_desc: Use image node_id 4 for calling the DiagonalMassMatrixAdaptationTest obj's underlying member method code with example usage: obj.testUpdatesCorrectly() without return types