code: def _apply_default_boundary(
      subdiag,
      diag,
      superdiag,
      inner_first_order_coeff,
      first_order_coeff,
      delta,
      has_default_lower_boundary,
      has_default_upper_boundary,
      lower_trim_indices,
      upper_trim_indices,
      batch_rank,
      dim,
  ):
      """Update discretization matrix for default boundary conditions."""
      # For default BC, we need to add spatial discretizations of
      # 'b * d(B * V)/dx' to the boundaries. Note that the zero-order term 'c * V'
      # is added elsewhere, and the second-order terms involving derivative w.r.t.
      # `dim` are assumed to be zero.
  
      # Updates for lower BC
      if has_default_lower_boundary[dim]:
          (subdiag, diag, superdiag) = _apply_default_lower_boundary(
              subdiag,
              diag,
              superdiag,
              inner_first_order_coeff,
              first_order_coeff,
              delta,
              lower_trim_indices,
              upper_trim_indices,
              batch_rank,
              dim,
          )
  
      # Updates for upper BC
      if has_default_upper_boundary[dim]:
          (subdiag, diag, superdiag) = _apply_default_upper_boundary(
              subdiag,
              diag,
              superdiag,
              inner_first_order_coeff,
              first_order_coeff,
              delta,
              lower_trim_indices,
              upper_trim_indices,
              batch_rank,
              dim,
          )
      return subdiag, diag, superdiag
  
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_boundary(subdiag, diag, superdiag, inner_first_order_coeff, first_order_coeff, delta, has_default_lower_boundary, has_default_upper_boundary, lower_trim_indices, upper_trim_indices, batch_rank, dim) and returns: subdiag,  diag,  superdiag