code: def test_sparse_regression_recovers_plausible_weights(
      self, use_dynamic_cholesky
  ):
      true_weights = tf.constant([0.0, 0.0, 2.0, 0.0, -2.0])
      model, observed_time_series, _ = self._build_test_model(
          num_timesteps=20,
          num_features=5,
          missing_prob=0.0,
          true_noise_scale=0.1,
          weights=true_weights,
          weights_prior_scale=None,  # Default g-prior.
          sparse_weights_nonzero_prob=0.4,
      )
  
      @tf.function(autograph=False)
      def do_sampling():
          return gibbs_sampler.fit_with_gibbs_sampling(
              model,
              observed_time_series,
              num_results=100,
              num_warmup_steps=100,
              seed=test_util.test_seed(sampler_type="stateless"),
              experimental_use_dynamic_cholesky=use_dynamic_cholesky,
          )
  
      if JAX_MODE and use_dynamic_cholesky:
          with self.assertRaises(ValueError):
              self.evaluate(do_sampling())
          return
      else:
          samples = self.evaluate(do_sampling())
      mean_weights = tf.reduce_mean(samples.weights, axis=-2)
      nonzero_probs = tf.reduce_mean(
          tf.cast(tf.not_equal(samples.weights, 0.0), tf.float32),
          axis=-2,
      )
      # Increasing `num_timesteps` relative to `num_features` would give more
      # precise weight estimates, at the cost of longer test runtime.
      # TODO(axch, cgs): Can we use assertAllMeansClose here too?  The
      # samples are presumably not IID across axis=0, so the
      # statistical assumptions are not satisfied.
      self.assertAllClose(mean_weights, true_weights, atol=0.3)
      self.assertAllClose(
          nonzero_probs, [0.0, 0.0, 1.0, 0.0, 1.0], atol=0.2
      )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import identity
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.bijectors import square
  from tensorflow_probability.python.distributions import inverse_gamma
  from tensorflow_probability.python.distributions import lognormal
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import student_t
  from tensorflow_probability.python.distributions import transformed_distribution
  from tensorflow_probability.python.distributions.linear_gaussian_ssm import linear_gaussian_update
  from tensorflow_probability.python.experimental.distributions import mvn_precision_factor_linop
  from tensorflow_probability.python.experimental.sts_gibbs import gibbs_sampler
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.stats import sample_stats
  from tensorflow_probability.python.sts.components import local_level
  from tensorflow_probability.python.sts.components import local_linear_trend
  from tensorflow_probability.python.sts.components import regression
  from tensorflow_probability.python.sts.components import seasonal
  from tensorflow_probability.python.sts.components import semilocal_linear_trend
  from tensorflow_probability.python.sts.components import sum
  from tensorflow_probability.python.sts.forecast import forecast
  from tensorflow_probability.python.sts.internal import missing_values_util
  from tensorflow_probability.python.sts.internal import util
label_desc: Use image node_id 13 for calling the GibbsSamplerTests obj's underlying member method code with example usage: obj.test_sparse_regression_recovers_plausible_weights(use_dynamic_cholesky) and returns: gibbs_sampler