code: def _find_matches(
      root: GraphModule,
      graph: Graph,
      pattern_to_fuse_handler_cls: Dict[Pattern, Callable],
  ) -> Dict[
      str,
      Tuple[Node, Pattern, NodePattern, FuseHandler, Dict[Node, Any]],
  ]:
      modules = dict(root.named_modules())
      # node name -> (root_node, match_value)
      match_map: Dict[
          str,
          Tuple[
              Node, Pattern, NodePattern, FuseHandler, Dict[Node, Any]
          ],
      ] = {}
      # a map from node to the matched subpattern
      node_to_subpattern: Dict[Node, Any] = {}
  
      # TODO: dedup with quantization matching function in match_utils.py
      def apply_match(
          pattern, node, match, matched_node_pattern, node_to_subpattern
      ):
          if isinstance(pattern, tuple):
              s, *args = pattern
              current_node_pattern: List[Node] = []
              apply_match(
                  s,
                  node,
                  match,
                  current_node_pattern,
                  node_to_subpattern,
              )
              for subpattern, arg in zip(args, node.args):
                  apply_match(
                      subpattern,
                      arg,
                      match,
                      current_node_pattern,
                      node_to_subpattern,
                  )
              matched_node_pattern.append(tuple(current_node_pattern))
          else:
              # the first pattern matches will take precedence
              if node.name not in match_map:
                  matched_node_pattern.append(node)
                  # MatchAllNode here is actually MatchAllInputNode which should not
                  # be added to match_map
                  if pattern is not MatchAllNode:
                      node_to_subpattern[node] = pattern
                      root_node, pattern, handler = match
                      match_map[node.name] = (
                          root_node,
                          pattern,
                          matched_node_pattern,
                          handler,
                          node_to_subpattern,
                      )
  
      for node in reversed(graph.nodes):
          if node.name not in match_map:
              for (
                  pattern,
                  fuse_handler_cls,
              ) in pattern_to_fuse_handler_cls.items():
                  matched_node_pattern: List[Node] = []
                  if _is_match(modules, node, pattern):
                      apply_match(
                          pattern,
                          node,
                          (node, pattern, fuse_handler_cls(node)),
                          matched_node_pattern,
                          node_to_subpattern,
                      )
                      break
  
      return match_map
  
file_path: pytorch/torch/ao/quantization/fx/fuse.py
imports: from torch.fx import GraphModule, Node, map_arg
  from torch.fx.graph import Graph
  from .match_utils import _is_match, MatchAllNode
  from .pattern_utils import _sorted_patterns_dict
  from ..backend_config import BackendConfig, get_native_backend_config
  from ..backend_config.utils import get_fuser_method_mapping, get_fusion_pattern_to_root_node_getter, get_fusion_pattern_to_extra_inputs_getter
  from .custom_config import FuseCustomConfig
  from .fuse_handler import _get_fusion_pattern_to_fuse_handler_cls, FuseHandler
  from typing import Any, Callable, Dict, List, Tuple, Union
  import warnings
  from torch.ao.quantization.utils import Pattern, NodePattern
label_desc: Use image node_id 2 for calling a global function with example usage: _find_matches(root, graph, pattern_to_fuse_handler_cls) and returns: match_map