code: def test_docstring_examples(self):
      # Case 1: argless `f`.
      x = tf.constant(2.0)
      self.assertAllClose(
          [np.log(2.0), 0.5],
          self.evaluate(
              gradient.value_and_gradient(lambda: tf.math.log(x), x)
          ),
          atol=1e-6,
          rtol=1e-6,
      )
  
      # Case 2: packed arguments.
      self.assertAllClose(
          [2.0 * np.log(3.0), (np.log(3.0), 2.0 / 3)],
          self.evaluate(
              gradient.value_and_gradient(
                  lambda x, y: x * tf.math.log(y), [2.0, 3.0]
              )
          ),
          atol=1e-6,
          rtol=1e-6,
      )
  
      # Case 3: default.
      x = np.array([1.0, 2, 3])
      self.assertAllClose(
          (np.log(x), 1.0 / x),
          self.evaluate(
              gradient.value_and_gradient(
                  tf.math.log,
                  [1.0, 2.0, 3.0],
                  auto_unpack_single_arg=False,
              )
          ),
          atol=1e-6,
          rtol=1e-6,
      )
  
imports: import numpy
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import kullback_leibler
  from tensorflow_probability.python.distributions import normal
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math.gradient import batch_jacobian
  from tensorflow_probability.python.math.gradient import value_and_gradient_with_auto_expansion
label_desc: Use image node_id 9 for calling the GradientTest obj's underlying member method code with example usage: obj.test_docstring_examples() without return types