class_docstr: The main matcher class. After instantiating the patterns should
  be added using the add_fixer method
docstr: The main interface with the bottom matcher. The tree is
  traversed from the bottom using the constructed
  automaton. Nodes are only checked once as the tree is
  retraversed. When the automaton fails, we give it one more
  shot(in case the above tree matches as a whole with the
  rejected leaf), then we break for the next leaf. There is the
  special case of multiple arguments(see code comments) where we
  recheck the nodes
  
  Args:
     The leaves of the AST tree to be matched
  
  Returns:
     A dictionary of node matches with fixers as the keys
docstr_tok: ["The","main","interface","with","the","bottom","matcher",".","The","tree","is","traversed","from","the","bottom","using","the","constructed","automaton",".","Nodes","are","only","checked","once","as","the","tree","is","retraversed",".","When","the","automaton","fails",",","we","give","it","one","more","shot","(","in","case","the","above","tree","matches","as","a","whole","with","the","rejected","leaf",")",",","then","we","break","for","the","next","leaf",".","There","is","the","special","case","of","multiple","arguments","(","see","code","comments",")","where","we","recheck","the","nodes","Args",":","The","leaves","of","the","AST","tree","to","be","matched","Returns",":","A","dictionary","of","node","matches","with","fixers","as","the","keys"]
code: def run(self, leaves):
      """The main interface with the bottom matcher. The tree is
      traversed from the bottom using the constructed
      automaton. Nodes are only checked once as the tree is
      retraversed. When the automaton fails, we give it one more
      shot(in case the above tree matches as a whole with the
      rejected leaf), then we break for the next leaf. There is the
      special case of multiple arguments(see code comments) where we
      recheck the nodes
  
      Args:
         The leaves of the AST tree to be matched
  
      Returns:
         A dictionary of node matches with fixers as the keys
      """
      current_ac_node = self.root
      results = defaultdict(list)
      for leaf in leaves:
          current_ast_node = leaf
          while current_ast_node:
              current_ast_node.was_checked = True
              for child in current_ast_node.children:
                  # multiple statements, recheck
                  if (
                      isinstance(child, pytree.Leaf)
                      and child.value == ";"
                  ):
                      current_ast_node.was_checked = False
                      break
              if current_ast_node.type == 1:
                  # name
                  node_token = current_ast_node.value
              else:
                  node_token = current_ast_node.type
  
              if node_token in current_ac_node.transition_table:
                  # token matches
                  current_ac_node = current_ac_node.transition_table[
                      node_token
                  ]
                  for fixer in current_ac_node.fixers:
                      if not fixer in results:
                          results[fixer] = []
                      results[fixer].append(current_ast_node)
  
              else:
                  # matching failed, reset automaton
                  current_ac_node = self.root
                  if (
                      current_ast_node.parent is not None
                      and current_ast_node.parent.was_checked
                  ):
                      # the rest of the tree upwards has been checked, next leaf
                      break
  
                  # recheck the rejected node once from the root
                  if node_token in current_ac_node.transition_table:
                      # token matches
                      current_ac_node = (
                          current_ac_node.transition_table[node_token]
                      )
                      for fixer in current_ac_node.fixers:
                          if not fixer in results.keys():
                              results[fixer] = []
                          results[fixer].append(current_ast_node)
  
              current_ast_node = current_ast_node.parent
      return results
  
file_path: catboost/contrib/tools/python/src/Lib/lib2to3/btm_matcher.py
imports: import logging
  import itertools
  from collections import defaultdict
  from .None import pytree
  from .btm_utils import reduce_tree
label_desc: Use image node_id 4 for calling the BottomMatcher obj's underlying member method code with example usage: obj.run(leaves) and returns: results