code: def _backward_pde_coeffs(drift_fn, volatility_fn, discounting):
      """Returns coeffs of the backward PDE."""
  
      def second_order_coeff_fn(t, coord_grid):
          volatility = volatility_fn(
              t, _coord_grid_to_mesh_grid(coord_grid)
          )
          volatility_times_volatility_t = tf.linalg.matmul(
              volatility, volatility, transpose_b=True
          )
  
          # We currently have [dim, dim] as innermost dimensions, but the returned
          # tensor must have [dim, dim] as outermost dimensions.
          rank = len(volatility.shape.as_list())
          perm = [rank - 2, rank - 1] + list(range(rank - 2))
          volatility_times_volatility_t = tf.transpose(
              volatility_times_volatility_t, perm
          )
          return volatility_times_volatility_t / 2
  
      def first_order_coeff_fn(t, coord_grid):
          mean = drift_fn(t, _coord_grid_to_mesh_grid(coord_grid))
  
          # We currently have [dim] as innermost dimension, but the returned
          # tensor must have [dim] as outermost dimension.
          rank = len(mean.shape.as_list())
          perm = [rank - 1] + list(range(rank - 1))
          mean = tf.transpose(mean, perm)
          return mean
  
      def zeroth_order_coeff_fn(t, coord_grid):
          if not discounting:
              return None
          return -discounting(t, _coord_grid_to_mesh_grid(coord_grid))
  
      return (
          second_order_coeff_fn,
          first_order_coeff_fn,
          zeroth_order_coeff_fn,
      )
  
imports: import tensorflow.compat.v2
  from tf_quant_finance import utils
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math.pde import fd_solvers
  from tf_quant_finance.models import ito_process
  from tf_quant_finance.models import utils
label_desc: Use image node_id 1 for calling a global function with example usage: _backward_pde_coeffs(drift_fn, volatility_fn, discounting) and returns: second_order_coeff_fn,  first_order_coeff_fn,  zeroth_order_coeff_fn, unknown, mean, unknown, None