code: def dead_code_elimination(node):
    
    to_remove = set(def_[1] for def_ in annotate.unused(node)
                    if not isinstance(def_[1], (gast.arguments, gast.For)))
    for n in list(to_remove):
      for succ in gast.walk(n):
        if anno.getanno(succ, 'push', False):
          to_remove.add(anno.getanno(succ, 'push'))
    transformers.Remove(to_remove).visit(node)
    anno.clearanno(node)
    return node
docs: Perform a simple form of dead code elimination on a Python AST.
  
    This method performs reaching definitions analysis on all function
    definitions. It then looks for the definition of variables that are not used
    elsewhere and removes those definitions.
  
    This function takes into consideration push and pop statements; if a pop
    statement is removed, it will also try to remove the accompanying push
    statement. Note that this *requires dead code elimination to be performed on
    the primal and adjoint simultaneously*.
  
    Args:
      node: The AST to optimize.
  
    Returns:
      The optimized AST.