code: def test_with_target_distribution_dim_one(self):
      stacked_particles = np.stack(
          [
              np.linspace(0.0, 500.0, num=2500, dtype=np.float32),
              np.linspace(0.17, 433.0, num=2500, dtype=np.float32),
          ],
          axis=0,
      )
  
      stacked_log_weights = poisson.Poisson(20.0).log_prob(
          stacked_particles
      )
  
      # Resample particles to target a Poisson(20.) distribution.
      new_particles, _, new_log_weights = resample(
          stacked_particles,
          stacked_log_weights,
          resample_fn=resample_systematic,
          particles_dim=1,
          seed=test_util.test_seed(sampler_type="stateless"),
      )
  
      self.assertAllMeansClose(
          new_particles, [20.0, 20.0], axis=1, atol=1e-2
      )
      self.assertAllClose(
          tf.reduce_sum(
              tf.nn.softmax(new_log_weights) * new_particles, axis=1
          ),
          [20.0, 20.0],
          atol=1e-2,
      )
  
      # Reweight the resampled particles to target a Poisson(30.) distribution.
      new_particles, _, new_log_weights = resample(
          stacked_particles,
          stacked_log_weights,
          resample_fn=resample_systematic,
          particles_dim=1,
          target_log_weights=poisson.Poisson(30).log_prob(
              stacked_particles
          ),
          seed=test_util.test_seed(sampler_type="stateless"),
      )
      self.assertAllMeansClose(
          new_particles, [20.0, 20.0], axis=1, atol=1e-2
      )
  
      self.assertAllClose(
          tf.reduce_sum(
              tf.nn.softmax(new_log_weights) * new_particles, axis=1
          ),
          [30.0, 30.0],
          atol=1.5,
      )
  
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 11 for calling the _SMCResamplersTest obj's underlying member method code with example usage: obj.test_with_target_distribution_dim_one() without return types