code: def _calculate_spline_coeffs_clamped_or_first_derivative(
      dx,
      dd,
      superdiag,
      subdiag,
      diag_values,
      rhs,
      dtype,
      boundary_condition_type,
      left_boundary_value=None,
      right_boundary_value=None,
  ):
      """Calculates the coefficients for the spline interpolation if the boundary condition type is CLAMPED/FIXED_FIRST_DERIVATIVE."""
      zero = tf.zeros_like(dx[..., :1], dtype=dtype)
      one = tf.ones_like(dx[..., :1], dtype=dtype)
      diag_values = tf.concat(
          [2.0 * dx[..., :1], diag_values, zero], axis=-1
      )
      superdiag = tf.concat([dx[..., :1], superdiag, zero], axis=-1)
      subdiag = tf.concat([zero, subdiag, dx[..., -1:]], axis=-1)
  
      # locate right boundary when duplicates exists
      dx = tf.concat((one, dx, zero), axis=-1)
      dx_right = dx[..., 1:]
      dx_left = dx[..., :-1]
      right_boundary = tf.math.logical_and(
          tf.equal(dx_right, 0), tf.not_equal(dx_left, 0)
      )
  
      # For diag_values, at the right boundary, fill the value as 2.0 * dx.
      # For the right padding beyond boundary, fill the default value as 1.0.
      # No need to operate on super_diag/sub_diag,
      # since dx[..., -1:] is already zero
      diag_values = tf.where(right_boundary, 2.0 * dx_left, diag_values)
      diag_values = tf.where(tf.equal(dx_left, 0), one, diag_values)
  
      # build diagonals
      diagonals = tf.stack([superdiag, diag_values, subdiag], axis=-2)
  
      # build rhs
      left_boundary_tensor = tf.zeros_like(dx[..., :1], dtype=dtype)
      right_boundary_tensor = tf.zeros_like(dx[..., :1], dtype=dtype)
      if (
          boundary_condition_type
          == BoundaryConditionType.FIXED_FIRST_DERIVATIVE
      ):
          left_boundary_tensor = tf.convert_to_tensor(
              left_boundary_value,
              dtype=dtype,
              name="left_boundary_value",
          )
          right_boundary_tensor = tf.convert_to_tensor(
              right_boundary_value,
              dtype=dtype,
              name="right_boundary_value",
          )
      top_rhs = 3.0 * (dd[..., :1] - left_boundary_tensor[..., :1])
      rhs = tf.concat([top_rhs, rhs, zero], axis=-1)
      # For rhs, at the right boundary, fill the value as bottom_rhs.
      # For the right padding beyond boundary, fill the default value as 0.0.
      dd_left = tf.concat((one, dd), axis=-1)
      bottom_rhs = -3.0 * (dd_left - right_boundary_tensor[..., :1])
      rhs = tf.where(right_boundary, bottom_rhs, rhs)
      rhs = tf.where(tf.equal(dd_left, 0), zero, rhs)
  
      spline_coeffs = tf.linalg.tridiagonal_solve(
          diagonals, rhs, partial_pivoting=False
      )
      return 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 4 for calling a global function with example usage: _calculate_spline_coeffs_clamped_or_first_derivative(dx, dd, superdiag, subdiag, diag_values, rhs, dtype, boundary_condition_type, left_boundary_value, right_boundary_value) and returns: spline_coeffs