code: def test_samples_approach_target_distribution(self):
      num_samples = 10_000
      seeds = samplers.split_seed(
          test_util.test_seed(sampler_type="stateless"), n=6
      )
  
      target = normal.Normal(loc=0.0, scale=2.0)
      proposal = student_t.StudentT(df=2, loc=-1.0, scale=3.0)
      resampled2 = importance_resample.ImportanceResample(
          proposal,
          target_log_prob_fn=target.log_prob,
          importance_sample_size=2,
      )
      resampled20 = importance_resample.ImportanceResample(
          proposal,
          target_log_prob_fn=target.log_prob,
          importance_sample_size=20,
      )
  
      xs = self.evaluate(target.sample(num_samples, seed=seeds[0]))
      xs2 = self.evaluate(resampled2.sample(num_samples, seed=seeds[1]))
      xs20 = self.evaluate(
          resampled20.sample(num_samples, seed=seeds[2])
      )
      for statistic_fn in (lambda x: x, lambda x: x**2):
          true_statistic = tf.reduce_mean(statistic_fn(xs))
          # Statistics should approach those of the target distribution as
          # `importance_sample_size` increases.
          self.assertAllGreater(
              tf.abs(
                  tf.reduce_mean(statistic_fn(xs2)) - true_statistic
              ),
              tf.abs(
                  tf.reduce_mean(statistic_fn(xs20)) - true_statistic
              ),
          )
  
          expectation_no_resampling = (
              resampled2.self_normalized_expectation(
                  statistic_fn,
                  importance_sample_size=10000,
                  seed=seeds[3],
              )
          )
          self.assertAllClose(
              true_statistic, expectation_no_resampling, atol=0.15
          )
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import categorical
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_coroutine
  from tensorflow_probability.python.distributions import mixture_same_family
  from tensorflow_probability.python.distributions import mvn_diag
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import student_t
  from tensorflow_probability.python.experimental.distributions import importance_resample
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.vi import csiszar_divergence
label_desc: Use image node_id 4 for calling the ImportanceResampleTest obj's underlying member method code with example usage: obj.test_samples_approach_target_distribution() without return types