code: def test_importance_resampled_surrogate_is_equivalent_to_iwae(self):
      importance_sample_size = 10
      sample_size = 1e4
      target = mvn_tril.MultivariateNormalTriL(
          loc=[1.0, -1.0], scale_tril=[[1.0, 0.0], [-2.0, 0.2]]
      )
      proposal = mvn_diag.MultivariateNormalDiag(
          loc=[0.0, 0.0], scale_diag=[1.0, 1.0]
      )
  
      stream = test_util.test_seed_stream()
      iwae_bound = self.evaluate(
          csiszar_divergence.monte_carlo_variational_loss(
              target_log_prob_fn=target.log_prob,
              surrogate_posterior=proposal,
              importance_sample_size=importance_sample_size,
              sample_size=sample_size,
              seed=stream(),
          )
      )
  
      elbo_with_resampled_surrogate = self.evaluate(
          csiszar_divergence.monte_carlo_variational_loss(
              target_log_prob_fn=target.log_prob,
              surrogate_posterior=importance_resample.ImportanceResample(
                  proposal,
                  target_log_prob_fn=target.log_prob,
                  importance_sample_size=importance_sample_size,
              ),
              sample_size=sample_size,
              seed=stream(),
          )
      )
      # Passes with `atol=0.015` and `sample_size = 1e6`.
      self.assertAllClose(
          iwae_bound, elbo_with_resampled_surrogate, 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 8 for calling the ImportanceResampleTest obj's underlying member method code with example usage: obj.test_importance_resampled_surrogate_is_equivalent_to_iwae() without return types