code: def testHalfCauchyGradientsAndValueFiniteAtLoc(self):
      batch_size = 1000
      loc_ = np.linspace(0.0, 100.0, batch_size)
      loc = self._create_placeholder_with_default(loc_, name="loc")
      scale = self._create_placeholder_with_default([1.0], name="scale")
      x = self._create_placeholder_with_default(loc_, name="x")
      # log_cdf does not have a finite gradient at `x = loc` and cdf,
      # survival_function, log_survival_function are all computed based on
      # log_cdf. So none of these functions have a finite gradient at `x = loc`.
      for func in [
          lambda loc, scale, x: half_cauchy.HalfCauchy(  # pylint: disable=g-long-lambda
              loc, scale, validate_args=True
          ).prob(
              x
          ),
          lambda loc, scale, x: half_cauchy.HalfCauchy(  # pylint: disable=g-long-lambda
              loc, scale, validate_args=True
          ).log_prob(
              x
          ),
      ]:
          value, grads = self.evaluate(
              gradient.value_and_gradient(func, [loc, scale, x])
          )
          self.assertAllFinite(value)
          for grad in grads:
              self.assertAllFinite(grad)
  
imports: import numpy
  from scipy import stats
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import half_cauchy
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 26 for calling the _HalfCauchyTest obj's underlying member method code with example usage: obj.testHalfCauchyGradientsAndValueFiniteAtLoc() without return types