class_docstr: Test for 1-D usage of tfp.math.interp_regular_1d_grid.
class_docstr_tok: ["Test","for","1-D","usage","of","tfp.math.interp_regular_1d_grid","."]
code: def test_gradients_and_propagation_of_nan_in_x(self):
      # If x contains NaN, this should propagate through to y, and not mess up the
      # gradients associated with finite members of x.
      # In fact, even NaN members of x result in finite (zero) gradients.
  
      x_min = 0.0
      x_max = 1.0
      dtype = np.float32
      num_pts = 4
  
      implied_x_ref = np.linspace(x_min, x_max, num_pts, dtype=dtype)
      y_ref = 2 * implied_x_ref
  
      x_ = np.array([0.0, 0.1, np.nan, 0.4, 1.0]).astype(dtype)
      y_expected = 2 * x_
  
      x = tf.constant(x_)
  
      y = interpolation.batch_interp_regular_1d_grid(
          x, x_min, x_max, y_ref
      )
      y_ = self.evaluate(y)
      self.assertAllClose(y_, y_expected, atol=0, rtol=1e-6)
      if not tf.executing_eagerly():
          dy_dx_ = self.evaluate(tf.gradients(ys=y, xs=x)[0])
          self.assertAllClose([2.0, 2.0, 0.0, 2.0, 2.0], dy_dx_)
  
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 13 for calling the BatchInterpRegular1DGridTest obj's underlying member method code with example usage: obj.test_gradients_and_propagation_of_nan_in_x() without return types