code: def testHorseshoeLogPDFGradient(self):
      scale = self.dtype(2.3)
      x = self._test_param(np.linspace(0.1, 10.1, 11))
      [
          dist_log_prob,
          dist_log_prob_gradient,
      ] = gradient.value_and_gradient(
          lambda x_: horseshoe.Horseshoe(
              scale=scale, validate_args=True
          ).log_prob(  # pylint: disable=g-long-lambda
              x_
          ),
          x,
      )
      # The expected derivative of log_prob can be explicitly derived from
      # PDF formula as shown in Horseshoe class docstring; it will have a
      # relatively simple form assuming PDF is known.
      k = 1 / np.sqrt(2 * np.pi**3)
      dist_log_prob_derivatives_expected = (
          x / scale**2
          - 2 * k * tf.exp(-dist_log_prob - tf.math.log(x * scale))
      )
      dist_log_prob_gradient_expected = tf.reshape(
          dist_log_prob_derivatives_expected,
          tf.shape(dist_log_prob_gradient),
      )
      self.assertAllClose(
          self.evaluate(dist_log_prob_gradient_expected),
          self.evaluate(dist_log_prob_gradient),
          # atol is not set to very tight and the max difference is observed
          # to be around 1e-3.
          atol=1.5e-3,
      )
  
imports: import numpy
  import scipy.stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import horseshoe
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 12 for calling the _HorseshoeTest obj's underlying member method code with example usage: obj.testHorseshoeLogPDFGradient() without return types