code: def testSampleLarge(self):
      mu = np.array([-1.0, 1], dtype=np.float32)
      scale_tril = np.array([[3.0, 0], [1, -2]], dtype=np.float32) / 3.0
  
      true_mean = mu
      true_scale = scale_tril
      true_covariance = np.matmul(true_scale, true_scale.T)
      true_variance = np.diag(true_covariance)
      true_stddev = np.sqrt(true_variance)
  
      dist = mvn_tril.MultivariateNormalTriL(
          loc=mu, scale_tril=scale_tril, validate_args=True
      )
  
      # The following distributions will test the KL divergence calculation.
      mvn_chol = mvn_tril.MultivariateNormalTriL(
          loc=np.array([0.5, 1.2], dtype=np.float32),
          scale_tril=np.array([[3.0, 0], [1, 2]], dtype=np.float32),
          validate_args=True,
      )
  
      n = int(10e3)
      samps = dist.sample(n, seed=test_util.test_seed())
      sample_mean = tf.reduce_mean(samps, axis=0)
      x = samps - sample_mean
      sample_covariance = tf.matmul(x, x, transpose_a=True) / n
  
      sample_kl_chol = tf.reduce_mean(
          dist.log_prob(samps) - mvn_chol.log_prob(samps), axis=0
      )
      analytical_kl_chol = kullback_leibler.kl_divergence(
          dist, mvn_chol
      )
  
      scale = dist.scale.to_dense()
  
      [
          sample_mean_,
          analytical_mean_,
          sample_covariance_,
          analytical_covariance_,
          analytical_variance_,
          analytical_stddev_,
          sample_kl_chol_,
          analytical_kl_chol_,
          scale_,
      ] = self.evaluate(
          [
              sample_mean,
              dist.mean(),
              sample_covariance,
              dist.covariance(),
              dist.variance(),
              dist.stddev(),
              sample_kl_chol,
              analytical_kl_chol,
              scale,
          ]
      )
  
      sample_variance_ = np.diag(sample_covariance_)
      sample_stddev_ = np.sqrt(sample_variance_)
  
      tf1.logging.vlog(2, "true_mean:\n{}  ".format(true_mean))
      tf1.logging.vlog(2, "sample_mean:\n{}".format(sample_mean_))
      tf1.logging.vlog(
          2, "analytical_mean:\n{}".format(analytical_mean_)
      )
  
      tf1.logging.vlog(
          2, "true_covariance:\n{}".format(true_covariance)
      )
      tf1.logging.vlog(
          2, "sample_covariance:\n{}".format(sample_covariance_)
      )
      tf1.logging.vlog(
          2, "analytical_covariance:\n{}".format(analytical_covariance_)
      )
  
      tf1.logging.vlog(2, "true_variance:\n{}".format(true_variance))
      tf1.logging.vlog(
          2, "sample_variance:\n{}".format(sample_variance_)
      )
      tf1.logging.vlog(
          2, "analytical_variance:\n{}".format(analytical_variance_)
      )
  
      tf1.logging.vlog(2, "true_stddev:\n{}".format(true_stddev))
      tf1.logging.vlog(2, "sample_stddev:\n{}".format(sample_stddev_))
      tf1.logging.vlog(
          2, "analytical_stddev:\n{}".format(analytical_stddev_)
      )
  
      tf1.logging.vlog(2, "true_scale:\n{}".format(true_scale))
      tf1.logging.vlog(2, "scale:\n{}".format(scale_))
  
      tf1.logging.vlog(
          2,
          "kl_chol:      analytical:{}  sample:{}".format(
              analytical_kl_chol_, sample_kl_chol_
          ),
      )
  
      self.assertAllClose(true_mean, sample_mean_, atol=0.0, rtol=0.03)
      self.assertAllClose(
          true_mean, analytical_mean_, atol=0.0, rtol=1e-6
      )
  
      self.assertAllClose(
          true_covariance, sample_covariance_, atol=0.0, rtol=0.04
      )
      self.assertAllClose(
          true_covariance, analytical_covariance_, atol=0.0, rtol=1e-6
      )
  
      self.assertAllClose(
          true_variance, sample_variance_, atol=0.0, rtol=0.02
      )
      self.assertAllClose(
          true_variance, analytical_variance_, atol=0.0, rtol=1e-6
      )
  
      self.assertAllClose(
          true_stddev, sample_stddev_, atol=0.0, rtol=0.01
      )
      self.assertAllClose(
          true_stddev, analytical_stddev_, atol=0.0, rtol=1e-6
      )
  
      self.assertAllClose(true_scale, scale_, atol=0.0, rtol=1e-6)
  
      self.assertAllClose(
          sample_kl_chol_, analytical_kl_chol_, atol=0.0, rtol=0.02
      )
  
imports: import os
  from absl.testing import parameterized
  import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import softplus
  from tensorflow_probability.python.bijectors import transform_diagonal
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 19 for calling the MultivariateNormalTriLTest obj's underlying member method code with example usage: obj.testSampleLarge() without return types