docstr: Verifies samples are consistent with the PDF using importance sampling.
  
  In particular, we verify an estimate the surface area of the n-dimensional
  hypersphere, and the surface areas of the spherical caps demarcated by
  a handful of survival rates.
  
  Args:
    uniform: A `SphericalUniform` distribution instance.
docstr_tok: ["Verifies","samples","are","consistent","with","the","PDF","using","importance","sampling",".","In","particular",",","we","verify","an","estimate","the","surface","area","of","the","n-dimensional","hypersphere",",","and","the","surface","areas","of","the","spherical","caps","demarcated","by","a","handful","of","survival","rates",".","Args",":","uniform",":","A","`","SphericalUniform","`","distribution","instance","."]
code: def VerifySampleAndPdfConsistency(self, uniform):
      """Verifies samples are consistent with the PDF using importance sampling.
  
      In particular, we verify an estimate the surface area of the n-dimensional
      hypersphere, and the surface areas of the spherical caps demarcated by
      a handful of survival rates.
  
      Args:
        uniform: A `SphericalUniform` distribution instance.
      """
      dim = tf.compat.dimension_value(uniform.event_shape[-1])
      nsamples = int(6e4)
      self.assertLess(
          self.evaluate(
              st.min_num_samples_for_dkwm_cdf_test(
                  discrepancy=0.04,
                  false_fail_rate=1e-9,
                  false_pass_rate=1e-9,
              )
          ),
          nsamples,
      )
      samples = uniform.sample(
          sample_shape=[nsamples], seed=test_util.test_seed()
      )
      samples = tf.debugging.check_numerics(samples, "samples")
      log_prob = uniform.log_prob(samples)
      log_prob = self.evaluate(
          tf.debugging.check_numerics(log_prob, "log_prob")
      )
      true_sphere_surface_area = (
          2
          * (np.pi) ** (dim / 2)
          * self.evaluate(tf.exp(-tf.math.lgamma(dim / 2)))
      )
      true_sphere_surface_area += np.zeros_like(log_prob)
      # Check the log prob is a constant and is the reciprocal of the surface
      # area.
      self.assertAllClose(
          np.exp(log_prob), 1.0 / true_sphere_surface_area
      )
  
      # For sampling, let's check the marginals. x_i**2 ~ Beta(0.5, d - 1 / 2)
      beta_dist = beta.Beta(
          self.dtype(0.5), self.dtype((dim - 1.0) / 2.0)
      )
      for i in range(dim):
          self.evaluate(
              st.assert_true_cdf_equal_by_dkwm(
                  samples[..., i] ** 2,
                  cdf=beta_dist.cdf,
                  false_fail_rate=1e-9,
              )
          )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import beta
  from tensorflow_probability.python.distributions import spherical_uniform
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import assert_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.stats import sample_stats
label_desc: Use image node_id 1 for calling the _SphericalUniformTest obj's underlying member method code with example usage: obj.VerifySampleAndPdfConsistency(uniform) without return types