code: def test_ildj_gradients(self):
      bij = sfwii.ScalarFunctionWithInferredInverse(lambda x: x**2)
      ys = tf.convert_to_tensor([0.25, 1.0, 4.0, 9.0])
      ildj, ildj_grad = gradient.value_and_gradient(
          lambda y: bij.inverse_log_det_jacobian(y, event_ndims=0), ys
      )
  
      # Compare ildjs from inferred inverses to ildjs from the true inverse.
      def ildj_fn(y):
          _, inverse_grads = gradient.value_and_gradient(tf.sqrt, y)
          return tf.math.log(tf.abs(inverse_grads))
  
      ildj_true, ildj_grad_true = gradient.value_and_gradient(
          ildj_fn, ys
      )
      self.assertAllClose(ildj, ildj_true, atol=1e-4)
      self.assertAllClose(ildj_grad, ildj_grad_true, rtol=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 5 for calling the ScalarFunctionWithInferredInverseTests obj's underlying member method code with example usage: obj.test_ildj_gradients() and returns: tf