output_to_node = {x.debugName(): n for n in graph.nodes()
for x in n.outputs()}
// build input mapping, from input debugName to its node
input_to_node = {x.debugName(): n for n in graph.nodes()
for x in n.inputs()}
// build module mapping, from module name to all nodes (as list) under this module scope
module_to_nodes = defaultdict(list)
// the mapping of function (non-module in forward) to nodes, key is scope name
func_to_nodes = defaultdict(list)
After Change
// associate module name with their trace graph nodes
for node in graph.nodes():
if node.kind() == CONSTANT_KIND:
continue
module_name = self._get_module_name(node.scopeName())
if module_name in self.leaf_modules:
module_to_nodes[module_name].append(node)
else: