code: def test_gradients_nonzero_at_reference_points(self):
      x_ref_min = [0.0]
      x_ref_max = [1.0]
  
      # Build y_ref.
      x0s = [0.0, 0.5, 1.0]
  
      def y_func(x0):
          return tf.convert_to_tensor(value=x0) * 2.0
  
      # Shape [3]
      y_ref = self.evaluate(y_func(x0s))
  
      x = [
          # Outside the grid
          # Grad will be 0, since outside the grid is in a "flat" region.
          [-1.0],
          # 0 is at the left reference pt.
          # Grad will be 2.
          [0.0],
          # 0.25 is in between reference pts.
          # Grad will be 2.
          [0.25],
          # Middle reference pt.
          # Grad will be 2.
          [0.5],
          # Right reference pt.
          # Grad will be 2.
          [1.0],
          # Outside the grid
          # Grad will be 0, since outside the grid is in a "flat" region.
          [2.0],
      ]
      x = tf.convert_to_tensor(value=x)
  
      def func(xx):
          return self.batch_interp_regular_nd_grid_fn(
              x=xx,
              x_ref_min=x_ref_min,
              x_ref_max=x_ref_max,
              y_ref=y_ref,
              axis=-1,
          )
  
      _, dy_dx_ = self.evaluate(gradient.value_and_gradient(func, x))
      self.assertAllEqual(
          [0.0, 2.0, 2.0, 2.0, 2.0, 0.0], dy_dx_[..., 0]
      )
  
imports: import numpy
  from scipy import interpolate
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math import interpolation
label_desc: Use image node_id 9 for calling the BaseBatchInterpNDGridTest obj's underlying member method code with example usage: obj.test_gradients_nonzero_at_reference_points() and returns: unknown, self