docstr: Verifies log_prob evaluations with numpy/scipy.
  
  Both uniform random points and sampled points are evaluated.
  
  Args:
    pspherical: A `tfp.distributions.PowerSpherical` instance.
    atol: Absolute difference tolerable.
docstr_tok: ["Verifies","log_prob","evaluations","with","numpy\/scipy",".","Both","uniform","random","points","and","sampled","points","are","evaluated",".","Args",":","pspherical",":","A","`","tfp.distributions.PowerSpherical","`","instance",".","atol",":","Absolute","difference","tolerable","."]
code: def VerifyPdfWithNumpy(self, pspherical, atol=1e-4):
      """Verifies log_prob evaluations with numpy/scipy.
  
      Both uniform random points and sampled points are evaluated.
  
      Args:
        pspherical: A `tfp.distributions.PowerSpherical` instance.
        atol: Absolute difference tolerable.
      """
      dim = tf.compat.dimension_value(pspherical.event_shape[-1])
      nsamples = 10
      # Sample some random points uniformly over the hypersphere using numpy.
      sample_shape = (
          [nsamples]
          + tensorshape_util.as_list(pspherical.batch_shape)
          + [dim]
      )
      uniforms = np.random.randn(*sample_shape)
      uniforms /= np.linalg.norm(uniforms, axis=-1, keepdims=True)
      uniforms = uniforms.astype(
          dtype_util.as_numpy_dtype(pspherical.dtype)
      )
      # Concatenate in some sampled points from the distribution under test.
      pspherical_samples = pspherical.sample(
          sample_shape=[nsamples], seed=test_util.test_seed()
      )
      samples = tf.concat([uniforms, pspherical_samples], axis=0)
      samples = tf.debugging.check_numerics(samples, "samples")
      samples = self.evaluate(samples)
      log_prob = pspherical.log_prob(samples)
      log_prob = self.evaluate(log_prob)
  
      # Check that the log_prob is not nan or +inf. It can be -inf since
      # if we sample a direction diametrically opposite to the mean direction,
      # we'll get an inner product of -1.
      self.assertFalse(np.any(np.isnan(log_prob)))
      self.assertFalse(np.any(np.isposinf(log_prob)))
      conc = self.evaluate(pspherical.concentration)
      mean_dir = self.evaluate(pspherical.mean_direction)
      alpha = (dim - 1.0) / 2.0 + conc
      beta = (dim - 1.0) / 2.0
  
      expected = (
          sp_special.xlog1py(conc, np.sum(samples * mean_dir, axis=-1))
          - (alpha + beta) * np.log(2.0)
          - beta * np.log(np.pi)
          - sp_special.gammaln(alpha)
          + sp_special.gammaln(alpha + beta)
      )
      self.assertAllClose(expected, log_prob, atol=atol)
  
imports: import numpy
  from scipy import special
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import power_spherical
  from tensorflow_probability.python.distributions import spherical_uniform
  from tensorflow_probability.python.distributions import von_mises_fisher
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import tensorshape_util
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.stats import sample_stats
label_desc: Use image node_id 6 for calling the _PowerSphericalTest obj's underlying member method code with example usage: obj.VerifyPdfWithNumpy(pspherical, atol) without return types