code: def test_stratified_resampler_means(self):
      strm = test_util.test_seed_stream()
      if self.use_xla and tf.executing_eagerly():
          self.skipTest(
              "No need to test XLA under all execution regimes."
          )
  
      # Distinct samples with this resampler aren't independent
      # so a chi-squared test is inappropriate.
      # However, because it reduces variance by design, we
      # can, with high probability,  place sharp bounds on the
      # values of the sample means.
      num_distributions = 3
      num_probs = 8
      probs = uniform.Uniform(
          low=self.dtype(0.0), high=self.dtype(1.0)
      ).sample([num_distributions, num_probs], seed=strm)
      probs = probs / tf.reduce_sum(probs, axis=-1, keepdims=True)
      num_samples = 4
      num_particles = 10000
      resampled = self.maybe_compiler(resample_stratified)(
          tf.math.log(
              dist_util.move_dimension(probs, source_idx=-1, dest_idx=0)
          ),
          num_particles,
          [num_samples],
          seed=test_util.test_seed_stream(),
      )
      resampled = dist_util.move_dimension(
          resampled, source_idx=0, dest_idx=-1
      )
      # TODO(dpiponi): reimplement this test in vectorized form rather than with
      # loops.
      for i in range(num_distributions):
          samples = _scatter_nd_batch(
              resampled[:, i, :, tf.newaxis],
              tf.ones((num_samples, num_particles)),
              (num_samples, num_probs),
              batch_dims=1,
          )
          # N.B.: _scatter_nd_batch returns numpy arrays in Eager mode
          wsamples = tf.convert_to_tensor(samples) / num_particles
          wsamples_, probs_ = self.evaluate([wsamples, probs[i]])
  
          self.assertAllMeansClose(wsamples_, probs_, axis=0, atol=0.1)
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import chi2
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import _resample_using_log_points
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import _scatter_nd_batch
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import resample
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import resample_deterministic_minimum_error
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import resample_independent
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import resample_stratified
  from tensorflow_probability.python.experimental.mcmc.weighted_resampling import resample_systematic
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import test_util
label_desc: Use image node_id 8 for calling the _SMCResamplersTest obj's underlying member method code with example usage: obj.test_stratified_resampler_means() without return types