class_docstr: An abstract helper for merging nodes
class_docstr_tok: ["An","abstract","helper","for","merging","nodes"]
code: def __call__(self, graph):  # type: (Graph) -> Graph
      nodes = graph.nodes
      merged_nodes = {}
      for node in nodes:
          nodes_window = []  # type: List[Node]
          n = node
          for _ in range(self.num_nodes - 1):
              if len(n.parents) != 1:
                  # We're only fusing nodes with single parents
                  break
              p = n.get_only_parent()
              if len(p.children) != 1:
                  # We can only fuse a node if its parent's
                  # value isn't used by any other node.
                  break
              nodes_window.insert(0, n)
              n = p
          if len(nodes_window) > 0:
              # add parent of chained nodes
              first = nodes_window[0]
              p = first.get_only_parent()
              if len(p.children) == 1:
                  nodes_window.insert(0, p)
          if len(nodes_window) != self.num_nodes:
              continue
          if not self.is_eligible(graph, nodes_window):
              continue
          merged = self.merge(graph, nodes_window)
          first, last = nodes_window[0], nodes_window[-1]
          for parent in first.parents:
              parent.children.remove(first)
              if merged[0] not in parent.children:
                  parent.add_child(merged[0])
          for child in last.children:
              child.parents.remove(last)
              if merged[-1] not in child.parents:
                  child.add_parent(merged[-1])
          for n in nodes_window:
              merged_nodes[n.name] = merged
  
      transformed_nodes = []
      added_merged = []  # type: List[Node]
      for node in nodes:
          if node.name in merged_nodes:
              merged = merged_nodes[node.name]
              if merged[0] not in added_merged:
                  for n in merged:
                      transformed_nodes.append(n)
                  added_merged.append(merged[0])
          else:
              transformed_nodes.append(node)
      return Graph(
          transformed_nodes,
          graph.inputs,
          graph.outputs,
          graph.shape_dict,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from typing import Sequence, Text, Dict, List
  import numpy
  from onnx import TensorProto
  from ._graph import Graph, Node
label_desc: Use image node_id 2 for calling the NodesFuser obj's underlying member method code with example usage: obj.__call__(graph) and returns: Graph