docstr: Verifies that dist's lps and gradients match those of Normal(0., 1.).
docstr_tok: ["Verifies","that","dist","'s","lps","and","gradients","match","those","of","Normal","(","0.",",","1",".",")","."]
code: def assertDistributionIsApproximatelyStandardNormal(
      self, dist, rtol=1e-6, logprob_atol=1e-2, grad_atol=1e-2
  ):
      """Verifies that dist's lps and gradients match those of Normal(0., 1.)."""
      batch_shape = dist.batch_shape_tensor()
  
      def make_reference_values(event_shape):
          dist_shape = ps.concat([batch_shape, event_shape], axis=0)
          x = tf.reshape(
              [-4.0, -2.0, 0.0, 2.0, 4.0],
              ps.concat([[5], ps.ones_like(dist_shape)], axis=0),
          )
          return tf.broadcast_to(
              x, ps.concat([[5], dist_shape], axis=0)
          )
  
      flat_event_shape = tf.nest.flatten(dist.event_shape_tensor())
      zs = [make_reference_values(s) for s in flat_event_shape]
      lp_dist, grad_dist = gradient.value_and_gradient(
          lambda *xs: dist.log_prob(
              tf.nest.pack_sequence_as(dist.dtype, xs)
          ),
          zs,
      )
  
      def reference_value_and_gradient(z, event_shape):
          reference_dist = independent.Independent(
              normal.Normal(loc=tf.zeros_like(z), scale=1.0),
              reinterpreted_batch_ndims=ps.rank_from_shape(event_shape),
          )
          return gradient.value_and_gradient(reference_dist.log_prob, z)
  
      reference_vals_and_grads = [
          reference_value_and_gradient(z, event_shape)
          for (z, event_shape) in zip(zs, flat_event_shape)
      ]
  
      lps_reference = [lp for lp, grad in reference_vals_and_grads]
      self.assertAllClose(
          sum(lps_reference), lp_dist, rtol=rtol, atol=logprob_atol
      )
  
      grads_reference = [grad for lp, grad in reference_vals_and_grads]
      self.assertAllCloseNested(
          grads_reference, grad_dist, rtol=rtol, atol=grad_atol
      )
  
imports: from absl.testing import parameterized
  import hypothesis
  from hypothesis import strategies
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import invert
  from tensorflow_probability.python.distributions import exponential
  from tensorflow_probability.python.distributions import hypothesis_testlib
  from tensorflow_probability.python.distributions import independent
  from tensorflow_probability.python.distributions import joint_distribution_auto_batched
  from tensorflow_probability.python.distributions import markov_chain
  from tensorflow_probability.python.distributions import mvn_tril
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental.bijectors import distribution_bijectors
  from tensorflow_probability.python.experimental.vi import automatic_structured_vi
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.internal import tf_keras
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.mcmc import dual_averaging_step_size_adaptation
  from tensorflow_probability.python.mcmc import nuts
  from tensorflow_probability.python.mcmc import sample
  from tensorflow_probability.python.mcmc import transformed_kernel
  from tensorflow_probability.python.vi import optimization
label_desc: Use image node_id 1 for calling the DistributionBijectorsTest obj's underlying member method code with example usage: obj.assertDistributionIsApproximatelyStandardNormal(dist, rtol, logprob_atol, grad_atol) and returns: tf, gradient