code: def forward_backward(sum_op, bin_op, expr, *, batch_vars=frozenset()):
      with AdjointTape() as tape:
          # TODO fix traversal order in AdjointTape instead of using stack_reinterpret
          forward = stack_reinterpret(expr)
      backward = tape.adjoint(
          sum_op, bin_op, forward, batch_vars=batch_vars
      )
      return forward, backward
  
imports: from collections import defaultdict
  from collections.abc import Hashable
  from funsor.cnf import Contraction
  from funsor.interpretations import Interpretation, reflect
  from funsor.interpreter import stack_reinterpret
  from funsor.ops import AssociativeOp
  from funsor.registry import KeyedRegistry
  from funsor.terms import Approximate, Binary, Cat, Funsor, Reduce, Scatter, Slice, Subs, substitute, to_funsor
  from .None import instrument, interpreter, ops
label_desc: Use image node_id 2 for calling a global function with example usage: forward_backward(sum_op, bin_op, expr) and returns: forward,  backward