code: def _append_boundaries(
      value_grid_in,
      inner_grid_out,
      coord_grid,
      boundary_conditions,
      has_default_lower_boundary,
      has_default_upper_boundary,
      lower_trim_indices,
      upper_trim_indices,
      batch_rank,
      t,
  ):
      """Calculates and appends boundary values after making a step."""
      # After we've updated the values in the inner part of the grid according to
      # the PDE, we append the boundary values calculated using the boundary
      # conditions.
      # This is done using the discretized form of the boundary conditions,
      # v0 = xi1 v1 + xi2 v2 + eta.
      # This is analogous to _append_boundaries in pde_kernels.py, except we have to
      # restore the boundaries in each dimension. For example, for n_dims=2,
      # inner_grid_out has dimensions (b, ny-2, nx-2), which then becomes
      # (b, ny, nx-2) and finally (b, ny, nx).
      grid = inner_grid_out
      for dim in range(len(coord_grid)):
          grid = _append_boundary(
              dim,
              batch_rank,
              boundary_conditions,
              has_default_lower_boundary,
              has_default_upper_boundary,
              lower_trim_indices,
              upper_trim_indices,
              coord_grid,
              value_grid_in,
              grid,
              t,
          )
      return grid
  
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
label_desc: Use image node_id 9 for calling a global function with example usage: _append_boundaries(value_grid_in, inner_grid_out, coord_grid, boundary_conditions, has_default_lower_boundary, has_default_upper_boundary, lower_trim_indices, upper_trim_indices, batch_rank, t) and returns: grid