code: def testPoissonLogPmfGradient(self):
      batch_size = 6
      lam = tf.constant([3.0] * batch_size)
      lam_v = 3.0
      # Only non-negative values, as negative ones cause nans in the expected
      # value.
      x = np.array([0.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=np.float32)
  
      _, dlog_pmf_dlam = self.evaluate(
          gradient.value_and_gradient(
              lambda lam: self._make_poisson(rate=lam).log_prob(x), lam
          )
      )
  
      # A finite difference approximation of the derivative.
      eps = 1e-6
      expected = (
          stats.poisson.logpmf(x, lam_v + eps)
          - stats.poisson.logpmf(x, lam_v - eps)
      ) / (2 * eps)
  
      self.assertEqual(dlog_pmf_dlam.shape, (batch_size,))
      self.assertAllClose(dlog_pmf_dlam, expected)
  
imports: import numpy
  from scipy import stats
  import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import poisson
  from tensorflow_probability.python.distributions.internal import statistical_testing
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import implementation_selection
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
label_desc: Use image node_id 7 for calling the PoissonTest obj's underlying member method code with example usage: obj.testPoissonLogPmfGradient() without return types