docstr: Test the deviation of the interpolated values from the actual.
docstr_tok: ["Test","the","deviation","of","the","interpolated","values","from","the","actual","."]
code: def test_duplicate_x_points_for_derivative(
      self, optimize_for_tpu, boundary_condition_type
  ):
      """Test the deviation of the interpolated values from the actual."""
      x_series = np.array([[1.0, 2.0, 3.0, 4.0, 4.0, 4.0, 4.0]])
      y_series = np.array([[3.0, 1.0, 5.0, 2.0, 2.0, 2.0, 2.0]])
      expected_left_boundary_derivative = 12.0 * x_series[..., -1:]
      expected_right_boundary_derivative = 34.0 * x_series[..., -1:]
      spline = self.build_spline(
          x_series,
          y_series,
          boundary_condition_type,
          np.float64,
          expected_left_boundary_derivative,
          expected_right_boundary_derivative,
      )
  
      delta = 0.001
      test_x = tf.constant(
          np.array([[1.0, 1.0 + delta, 4.0 - delta, 4.0]]),
          dtype=tf.float64,
      )
      interpolated_y = tff.math.interpolation.cubic.interpolate(
          test_x, spline, optimize_for_tpu=optimize_for_tpu
      )
      actual_left_boundary_derivative = (
          interpolated_y[0][1] - interpolated_y[0][0]
      ) / (test_x[0][1] - test_x[0][0])
      actual_right_boundary_derivative = (
          interpolated_y[0][3] - interpolated_y[0][2]
      ) / (test_x[0][3] - test_x[0][2])
      if boundary_condition_type == cubic.BoundaryConditionType.CLAMPED:
          expected_left_boundary_derivative = 0.0
          expected_right_boundary_derivative = 0.0
      actual_left_boundary_derivative = self.evaluate(
          actual_left_boundary_derivative
      )
      actual_right_boundary_derivative = self.evaluate(
          actual_right_boundary_derivative
      )
      deviation_left_boundary = abs(
          actual_left_boundary_derivative
          - expected_left_boundary_derivative
      )
      deviation_right_boundary = abs(
          actual_right_boundary_derivative
          - expected_right_boundary_derivative
      )
      if expected_left_boundary_derivative != 0:
          deviation_left_boundary = (
              deviation_left_boundary
              / expected_left_boundary_derivative
          )
      if expected_right_boundary_derivative != 0:
          deviation_right_boundary = (
              deviation_right_boundary
              / expected_right_boundary_derivative
          )
      limit = 0.02
      self.assertLess(deviation_left_boundary, limit)
      self.assertLess(deviation_right_boundary, limit)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tensorflow_probability
  import tf_quant_finance
  from tensorflow.python.framework import test_util
  from tf_quant_finance.math.interpolation import cubic
label_desc: Use image node_id 3 for calling the CubicInterpolationTest obj's underlying member method code with example usage: obj.test_duplicate_x_points_for_derivative(optimize_for_tpu, boundary_condition_type) without return types