code: def test_transformed_distribution_log_prob_and_grads(self):
      dist = normal.Normal(loc=0.0, scale=1.0)
      xs = self.evaluate(dist.sample(100, seed=test_util.test_seed()))
      lp_true, lp_grad_true = gradient.value_and_gradient(
          dist.log_prob, xs
      )
  
      # Define a normal distribution using inverse-CDF sampling. Computing
      # log probs under this definition requires inverting the quantile function,
      # i.e., numerically approximating `normal.cdf`.
      u = uniform.Uniform(low=0, high=1.0)
      inverse_transform_normal = sfwii.ScalarFunctionWithInferredInverse(
          fn=dist.quantile,
          domain_constraint_fn=u.experimental_default_event_space_bijector(),
      )(
          u
      )
      lp, lp_grad = gradient.value_and_gradient(
          inverse_transform_normal.log_prob, xs
      )
      self.assertAllClose(lp_true, lp, atol=1e-4)
      self.assertAllClose(lp_grad_true, lp_grad, atol=1e-4)
  
imports: from absl.testing import parameterized
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.bijectors import chain
  from tensorflow_probability.python.bijectors import power
  from tensorflow_probability.python.bijectors import scale
  from tensorflow_probability.python.bijectors import shift
  from tensorflow_probability.python.distributions import beta
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.distributions import student_t
  from tensorflow_probability.python.distributions import uniform
  from tensorflow_probability.python.experimental.bijectors import scalar_function_with_inferred_inverse
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 4 for calling the ScalarFunctionWithInferredInverseTests obj's underlying member method code with example usage: obj.test_transformed_distribution_log_prob_and_grads() without return types