code: def visit(self, node):
      
      method = 'visit_' + node.__class__.__name__
      if not hasattr(self, method):
        raise ValueError('Unknown node type: %s' % node.__class__.__name__)
      visitor = getattr(self, method)
  
      # If this node is a statement, inform all child nodes what the active
      # variables in this statement are
      if anno.hasanno(node, 'active_in'):
        self.active_variables = anno.getanno(node, 'active_in')
      pri, adj = visitor(node)
  
      # Annotate primal and adjoint statements
      if isinstance(pri, gast.AST):
        anno.setdefaultanno(pri, 'adj', adj)
      else:
        for node in pri:
          anno.setdefaultanno(node, 'adj', adj)
      if isinstance(adj, gast.AST):
        anno.setdefaultanno(adj, 'pri', pri)
      else:
        for node in adj:
          anno.setdefaultanno(node, 'pri', pri)
  
      return pri, adj
docs: Visit a node.
  
      This method is largely modelled after the ast.NodeTransformer class.
  
      Args:
        node: The node to visit.
  
      Returns:
        A tuple of the primal and adjoint, each of which is a node or a list of
        nodes.