code: def build(
      x_data: types.RealTensor,
      y_data: types.RealTensor,
      boundary_condition_type: BoundaryConditionType = None,
      left_boundary_value: types.RealTensor = None,
      right_boundary_value: types.RealTensor = None,
      validate_args: bool = False,
      dtype: tf.DType = None,
      name=None,
  ) -> SplineParameters:
      """Builds a SplineParameters interpolation object.
  
      Given a `Tensor` of state points `x_data` and corresponding values `y_data`
      creates an object that contains interpolation coefficients. The object can be
      used by the `interpolate` function to get interpolated values for a set of
      state points `x` using the cubic spline interpolation algorithm.
      It assumes that the second derivative at the first and last spline points
      are zero. The basic logic is explained in [1] (see also, e.g., [2]).
  
      Repeated entries in `x_data` are only allowed for the *right* boundary values
      of `x_data`.
      For example, `x_data` can be `[1., 2, 3. 4., 4., 4.]` but not
      `[1., 1., 2., 3.]`. The repeated values play no role in interpolation and are
      useful only for interpolating multiple splines with different numbers of data
      point. It is user responsibility to verify that the corresponding
      values of `y_data` are the same for the repeated values of `x_data`.
  
      Typical Usage Example:
  
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
      import numpy as np
  
      x_data = tf.linspace(-5.0, 5.0,  num=11)
      y_data = 1.0/(1.0 + x_data**2)
      spline = tff.math.interpolation.cubic.build_spline(x_data, y_data)
      x_args = [3.3, 3.4, 3.9]
  
      tff.math.interpolation.cubic.interpolate(x_args, spline)
      # Expected: [0.0833737 , 0.07881707, 0.06149562]
      ```
  
      #### References:
      [1]: R. Sedgewick, Algorithms in C, 1990, p. 545-550.
        Link: https://api.semanticscholar.org/CorpusID:10976311
      [2]: R. Pienaar, M Choudhry. Fitting the term structure of interest rates:
        the practical implementation of cubic spline methodology.
        Link:
        http://yieldcurve.com/mktresearch/files/PienaarChoudhry_CubicSpline2.pdf
  
      Args:
        x_data: A real `Tensor` of shape `[..., num_points]` containing
          X-coordinates of points to fit the splines to. The values have to be
          monotonically non-decreasing along the last dimension.
        y_data: A `Tensor` of the same shape and `dtype` as `x_data` containing
          Y-coordinates of points to fit the splines to.
        boundary_condition_type: Boundary condition type for current cubic
          interpolation. Instance of BoundaryConditionType enum.
          Default value: `None` which maps to `BoundaryConditionType.NATURAL`.
        left_boundary_value: Set to non-empty value IFF boundary_condition_type is
          FIXED_FIRST_DERIVATIVE, in which case set to cubic spline's first
          derivative at `x_data[..., 0]`.
        right_boundary_value: Set to non-empty value IFF boundary_condition_type is
          FIXED_FIRST_DERIVATIVE, in which case set to cubic spline's first
          derivative at `x_data[..., num_points - 1]`.
        validate_args: Python `bool`. When `True`, verifies if elements of `x_data`
          are sorted in the last dimension in non-decreasing order despite possibly
          degrading runtime performance.
          Default value: False.
        dtype: Optional dtype for both `x_data` and `y_data`.
          Default value: `None` which maps to the default dtype inferred by
            TensorFlow.
        name: Python `str` name prefixed to ops created by this function.
          Default value: `None` which is mapped to the default name
            `cubic_spline_build`.
  
      Returns:
        An instance of `SplineParameters`.
      """
      if boundary_condition_type is None:
          boundary_condition_type = BoundaryConditionType.NATURAL
      if name is None:
          name = "cubic_spline_build"
      with tf.name_scope(name):
          x_data = tf.convert_to_tensor(
              x_data, dtype=dtype, name="x_data"
          )
          y_data = tf.convert_to_tensor(
              y_data, dtype=dtype, name="y_data"
          )
          # Sanity check inputs
          if validate_args:
              assert_sanity_check = [_validate_arguments(x_data)]
          else:
              assert_sanity_check = []
          x_data, y_data = tff_utils.broadcast_common_batch_shape(
              x_data, y_data
          )
  
          if (
              boundary_condition_type
              == BoundaryConditionType.FIXED_FIRST_DERIVATIVE
          ):
              if (
                  left_boundary_value is None
                  or right_boundary_value is None
              ):
                  raise ValueError(
                      "Expected non-empty left_boundary_value/right_boundary_value when "
                      "boundary_condition_type is FIXED_FIRST_DERIVATIVE, actual "
                      "left_boundary_value {0}, actual right_boundary_value {1}".format(
                          left_boundary_value, right_boundary_value
                      )
                  )
          with tf.compat.v1.control_dependencies(assert_sanity_check):
              spline_coeffs = _calculate_spline_coeffs(
                  x_data,
                  y_data,
                  boundary_condition_type,
                  left_boundary_value,
                  right_boundary_value,
              )
  
          return SplineParameters(
              x_data=x_data, y_data=y_data, spline_coeffs=spline_coeffs
          )
  
file_path: tf-quant-finance/tf_quant_finance/math/interpolation/cubic/cubic_interpolation.py
imports: import enum
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
label_desc: Use image node_id 1 for calling a global function with example usage: build(x_data, y_data, boundary_condition_type, left_boundary_value, right_boundary_value, validate_args, dtype, name) and returns: SplineParameters