code: def test_sanity_check_sweep_over_features(self):
      num_outputs = 100
      num_features = 3
      design_matrix, true_weights, targets = self.evaluate(
          self._random_regression_task(
              num_outputs=num_outputs,
              num_features=num_features,
              # Specify weights with a clear sparsity pattern.
              weights=tf.convert_to_tensor([10.0, 0.0, -10.0]),
              seed=test_util.test_seed(),
          )
      )
  
      sampler = dynamic_spike_and_slab.DynamicSpikeSlabSampler(
          design_matrix,
          # Ensure the probability of keeping an irrelevant feature is tiny.
          nonzero_prior_prob=1e-6,
      )
      initial_state = sampler._initialize_sampler_state(
          targets=targets,
          nonzeros=tf.convert_to_tensor([True, True, True]),
      )
      final_state = self.evaluate(
          sampler._resample_all_features(
              initial_state, seed=test_util.test_seed()
          )
      )
  
      # Check that we recovered the true sparsity pattern and approximate weights.
      weights_posterior_precision = (
          sampler.x_transpose_x + sampler.weights_prior_precision
      )
      conditional_weights_mean = _compute_conditional_weights_mean(
          final_state.nonzeros,
          weights_posterior_precision,
          final_state.x_transpose_y,
      )
      self.assertAllEqual(final_state.nonzeros, [True, False, True])
      indices = tf.where(final_state.nonzeros)
      conditional_weights_mean = tf.scatter_nd(
          indices, conditional_weights_mean, true_weights.shape
      )
      self.assertAllClose(
          conditional_weights_mean, true_weights, rtol=0.05, atol=0.15
      )
  
      posterior = sampler._get_conditional_posterior(final_state)
      posterior_variances, posterior_weights = self.evaluate(
          posterior.sample(seed=test_util.test_seed())
      )
      self.assertAllFinite(posterior_variances)
      self.assertAllFinite(posterior_weights)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import inverse_gamma
  from tensorflow_probability.python.distributions import normal_conjugate_posteriors
  from tensorflow_probability.python.experimental.sts_gibbs import dynamic_spike_and_slab
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.mcmc.internal import util
label_desc: Use image node_id 6 for calling the SpikeAndSlabTest obj's underlying member method code with example usage: obj.test_sanity_check_sweep_over_features() without return types