code: def douglas_adi_step(theta=0.5):
      """Creates a stepper function with Crank-Nicolson time marching scheme.
  
      Douglas ADI scheme is the simplest time marching scheme for solving parabolic
      PDEs with multiple spatial dimensions. The time step consists of several
      substeps: the first one is fully explicit, and the following `N` steps are
      implicit with respect to contributions of one of the `N` axes (hence "ADI" -
      alternating direction implicit). See `douglas_adi_scheme` below for more
      details.
  
      Args:
        theta: positive Number. `theta = 0` corresponds to fully explicit scheme.
        The larger `theta` the stronger are the corrections by the implicit
        substeps. The recommended value is `theta = 0.5`, because the scheme is
        second order accurate in that case, unless mixed second derivative terms are
        present in the PDE.
      Returns:
        Callable to be used in finite-difference PDE solvers (see fd_solvers.py).
      """
  
      def _step_fn(
          time,
          next_time,
          coord_grid,
          value_grid,
          boundary_conditions,
          second_order_coeff_fn,
          first_order_coeff_fn,
          zeroth_order_coeff_fn,
          inner_second_order_coeff_fn,
          inner_first_order_coeff_fn,
          num_steps_performed,
          dtype=None,
          name=None,
      ):
          """Performs the step."""
          del num_steps_performed
          name = name or "douglas_adi_step"
          return multidim_parabolic_equation_step(
              time,
              next_time,
              coord_grid,
              value_grid,
              boundary_conditions,
              douglas_adi_scheme(theta),
              second_order_coeff_fn,
              first_order_coeff_fn,
              zeroth_order_coeff_fn,
              inner_second_order_coeff_fn,
              inner_first_order_coeff_fn,
              dtype=dtype,
              name=name,
          )
  
      return _step_fn
  
file_path: tf-quant-finance/tf_quant_finance/math/pde/steppers/douglas_adi.py
imports: import numpy
  import tensorflow.compat.v2
  from tf_quant_finance.math.pde.steppers.multidim_parabolic_equation_stepper import multidim_parabolic_equation_step
label_desc: Use image node_id 1 for calling a global function with example usage: douglas_adi_step(theta) and returns: _step_fn, multidim_parabolic_equation_step