code: def adjoint_subs(adj_sum_op, adj_prod_op, out_adj, arg, subs):
      # detect fresh variable collisions that should be relabeled and reduced
      relabel = {k: interpreter.gensym(k) for k, v in subs}
      relabeled_subs = tuple((relabel[k], v) for k, v in subs)
      relabeled_arg = arg(**relabel)
  
      reduced_vars = out_adj.input_vars - relabeled_arg.input_vars
      for k, v in subs:
          reduced_vars |= v.input_vars - relabeled_arg.input_vars
  
      relabeled_arg_adj = Scatter(
          adj_sum_op, relabeled_subs, out_adj, reduced_vars
      )
      arg_adj = relabeled_arg_adj(**{v: k for k, v in relabel.items()})
      return ((arg, arg_adj),)
  
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 11 for calling a global function with example usage: adjoint_subs(adj_sum_op, adj_prod_op, out_adj, arg, subs) and returns: arg,  arg_adj