code: def _apply_default_upper_boundary(
      subdiag,
      diag,
      superdiag,
      zeroth_order_coeff,
      inner_first_order_coeff,
      first_order_coeff,
      backward_deltas,
      batch_shape,
  ):
      """Update discretization matrix for default upper boundary conditions."""
      # TODO(b/185337444): Use second order discretization for the boundary points
      # Here we append '-b(t, x_min) * (B(t, x_max) * V(t, x_max)) / delta' to
      # diagonal and
      # 'b(t, x_max) * (B(t, x_max - delta) * V(t, x_max - delta)) / delta' to
      # subdiagonal
      # Update diagonal
      if inner_first_order_coeff is None:
          inner_coeff = tf.constant([1, 1], dtype=diag.dtype)
      else:
          inner_coeff = inner_first_order_coeff
      if first_order_coeff is None:
          if inner_first_order_coeff is None:
              # Corresponds to B(t, x_max)
              extra_first_order_coeff = tf.zeros(
                  batch_shape, dtype=diag.dtype
              )
          else:
              extra_first_order_coeff = tf.ones(
                  batch_shape, dtype=diag.dtype
              )
      else:
          extra_first_order_coeff = first_order_coeff[..., -1]
      extra_diag_coeff = (
          inner_coeff[..., -1]
          * extra_first_order_coeff
          / backward_deltas[..., -1]
          + zeroth_order_coeff[..., -1]
      )
      # Minus is due to moving to rhs.
      diag = _append_last(diag, -extra_diag_coeff)
      # Update subdiagonal
      extra_sub_coeff = (
          -inner_coeff[..., -2]
          * extra_first_order_coeff
          / backward_deltas[..., -1]
      )
      # Minus is due to moving to rhs.
      subdiag = _append_last(subdiag, -extra_sub_coeff)
      # Update superdiag
      superdiag = _append_last(
          superdiag, -tf.zeros_like(extra_diag_coeff)
      )
      return subdiag, diag, superdiag
  
file_path: tf-quant-finance/tf_quant_finance/math/pde/steppers/parabolic_equation_stepper.py
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
label_desc: Use image node_id 5 for calling a global function with example usage: _apply_default_upper_boundary(subdiag, diag, superdiag, zeroth_order_coeff, inner_first_order_coeff, first_order_coeff, backward_deltas, batch_shape) and returns: subdiag,  diag,  superdiag