code: def generic_visit(self, node):
      node_name = self.node_id
      self.node_id += 1
  
      # if available, extract AST node attributes
      name = getattr(node, "name", None)
      arg = getattr(node, "arg", None)
      s = getattr(node, "s", None)
      n = getattr(node, "n", None)
      id_ = getattr(node, "id", None)
      attr = getattr(node, "attr", None)
  
      values = [name, arg, s, n, id_, attr]
      node_value = next(
          (str(value) for value in values if value is not None), None
      )
      if isinstance(node_value, str):
          node_value = node_value.encode(
              "utf-8", errors="surrogatepass"
          )
  
      # encapsulate all node features in a dict
      self.nodes[node_name] = {
          "type": type(node).__name__,
          "attribute": node_value.decode("UTF-8")
          if node_value is not None
          else node_value,
          "attributed": True if node_value != None else False,
          "depth": len(self.stack),
          "dfs_order": node_name,
      }
  
      # DFS traversal logic
      parent_name = None
      if self.stack:
          parent_name = self.stack[-1]
      self.stack.append(node_name)
      self.graph.add_node(node_name)
      if parent_name != None:
          # replicate AST as NetworkX object
          self.graph.add_edge(node_name, parent_name)
      super().generic_visit(node)
      self.stack.pop()
  
file_path: ogb/examples/graphproppred/code2/py2graph.py
imports: import ast
  import networkx
  import os
  import pandas
  import numpy
label_desc: Use image node_id 2 for calling the OGB_ASTWalker obj's underlying member method code with example usage: obj.generic_visit(node) without return types