code: def _construct_discretized_equation_params(
      coord_grid,
      value_grid,
      boundary_conditions,
      has_default_lower_boundary,
      has_default_upper_boundary,
      lower_trim_indices,
      upper_trim_indices,
      second_order_coeff_fn,
      first_order_coeff_fn,
      zeroth_order_coeff_fn,
      inner_second_order_coeff_fn,
      inner_first_order_coeff_fn,
      batch_rank,
      t,
  ):
      """Constructs parameters of discretized equation."""
      second_order_coeffs = second_order_coeff_fn(t, coord_grid)
      first_order_coeffs = first_order_coeff_fn(t, coord_grid)
      zeroth_order_coeffs = zeroth_order_coeff_fn(t, coord_grid)
      inner_second_order_coeffs = inner_second_order_coeff_fn(
          t, coord_grid
      )
      inner_first_order_coeffs = inner_first_order_coeff_fn(
          t, coord_grid
      )
  
      matrix_params = []
      inhomog_terms = []
  
      zeroth_order_coeffs = _prepare_pde_coeff(
          zeroth_order_coeffs, value_grid
      )
      if zeroth_order_coeffs is not None:
          zeroth_order_coeffs = _trim_boundaries(
              zeroth_order_coeffs,
              from_dim=batch_rank,
              lower_trim_indices=lower_trim_indices,
              upper_trim_indices=upper_trim_indices,
          )
  
      n_dims = len(coord_grid)
      for dim in range(n_dims):
          # 1. Construct contributions of dV/dx_dim and d^2V/dx_dim^2. This yields
          # a tridiagonal matrix.
          delta = _get_grid_delta(
              coord_grid, dim
          )  # Non-uniform grids not supported.
          second_order_coeff = second_order_coeffs[dim][dim]
          first_order_coeff = first_order_coeffs[dim]
          inner_second_order_coeff = inner_second_order_coeffs[dim][dim]
          inner_first_order_coeff = inner_first_order_coeffs[dim]
          # Broadcast to value_grid.shape
          second_order_coeff = _prepare_pde_coeff(
              second_order_coeff, value_grid
          )
          first_order_coeff = _prepare_pde_coeff(
              first_order_coeff, value_grid
          )
          inner_second_order_coeff = _prepare_pde_coeff(
              inner_second_order_coeff, value_grid
          )
          inner_first_order_coeff = _prepare_pde_coeff(
              inner_first_order_coeff, value_grid
          )
          superdiag, diag, subdiag = _construct_tridiagonal_matrix(
              value_grid,
              second_order_coeff,
              first_order_coeff,
              inner_second_order_coeff,
              inner_first_order_coeff,
              delta,
              dim,
              batch_rank,
              lower_trim_indices,
              upper_trim_indices,
              has_default_lower_boundary,
              has_default_upper_boundary,
              n_dims,
          )
          # 2. Apply the default BC, if needed. This adds extra points to the diagonal
          # terms coming from discretization of 'b_i * d(B_i * V)/dx'. Note that the
          # zero term 'c * V' is excluded from discretization and added in step 4
          # below.
          [subdiag, diag, superdiag] = _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,
          )
          # 3. Account for Robin boundary conditions on boundaries orthogonal to dim.
          # This modifies the first and last row of the tridiagonal matrix and also
          # yields a contribution to the inhomogeneous term
          (
              superdiag,
              diag,
              subdiag,
          ), inhomog_term_contribution = _apply_robin_boundary_conditions(
              value_grid,
              dim,
              batch_rank,
              boundary_conditions,
              has_default_lower_boundary,
              has_default_upper_boundary,
              lower_trim_indices,
              upper_trim_indices,
              coord_grid,
              superdiag,
              diag,
              subdiag,
              delta,
              t,
          )
          # 4. Evenly distribute shift term among tridiagonal matrices of each
          # dimension. The minus sign is because we move the shift term to rhs.
          if zeroth_order_coeffs is not None:
              # pylint: disable=invalid-unary-operand-type
              diag += -zeroth_order_coeffs / n_dims
  
          matrix_params_row = [None] * dim + [
              (superdiag, diag, subdiag)
          ]
  
          # 5. Construct contributions of mixed terms, d^2V/(dx_dim dx_dim2).
          for dim2 in range(dim + 1, n_dims):
              mixed_coeff = second_order_coeffs[dim][dim2]
              inner_mixed_coeff = inner_second_order_coeffs[dim][dim2]
              (
                  mixed_term_contrib
              ) = _construct_contribution_of_mixed_term(
                  mixed_coeff,
                  inner_mixed_coeff,
                  coord_grid,
                  value_grid,
                  dim,
                  dim2,
                  batch_rank,
                  lower_trim_indices,
                  upper_trim_indices,
                  has_default_lower_boundary,
                  has_default_upper_boundary,
                  n_dims,
              )
              matrix_params_row.append(mixed_term_contrib)
          matrix_params.append(matrix_params_row)
          inhomog_terms.append(inhomog_term_contribution)
  
      return matrix_params, inhomog_terms
  
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
label_desc: Use image node_id 2 for calling a global function with example usage: _construct_discretized_equation_params(coord_grid, value_grid, boundary_conditions, has_default_lower_boundary, has_default_upper_boundary, lower_trim_indices, upper_trim_indices, second_order_coeff_fn, first_order_coeff_fn, zeroth_order_coeff_fn, inner_second_order_coeff_fn, inner_first_order_coeff_fn, batch_rank, t) and returns: matrix_params,  inhomog_terms