class_docstr: A set of rewrite rules.
  
  Forms a structure for fast rewriting over a set of rewrite rules. This
  allows for syntactic matching of terms to patterns for many patterns at
  the same time.
  
  Examples
  --------
  
  >>> def f(*args): pass
  >>> def g(*args): pass
  >>> def h(*args): pass
  >>> from operator import add
  
  >>> rs = RuleSet(                 # Make RuleSet with two Rules
  ...         RewriteRule((add, 'x', 0), 'x', ('x',)),
  ...         RewriteRule((f, (g, 'x'), 'y'),
  ...                     (h, 'x', 'y'),
  ...                     ('x', 'y')))
  
  >>> rs.rewrite((add, 2, 0))       # Apply ruleset to single task
  2
  
  >>> rs.rewrite((f, (g, 'a', 3)))  # doctest: +ELLIPSIS
  (<function h at ...>, 'a', 3)
  
  >>> dsk = {'a': (add, 2, 0),      # Apply ruleset to full dask graph
  ...        'b': (f, (g, 'a', 3))}
  
  Attributes
  ----------
  rules : list
      A list of `RewriteRule`s included in the `RuleSet`.
class_docstr_tok: ["A","set","of","rewrite","rules",".","Forms","a","structure","for","fast","rewriting","over","a","set","of","rewrite","rules",".","This","allows","for","syntactic","matching","of","terms","to","patterns","for","many","patterns","at","the","same","time",".","Examples","--","--","--","--",">",">",">","def","f","(","*","args",")",":","pass",">",">",">","def","g","(","*","args",")",":","pass",">",">",">","def","h","(","*","args",")",":","pass",">",">",">","from","operator","import","add",">",">",">","rs","=","RuleSet","(","#","Make","RuleSet","with","two","Rules","...","RewriteRule","(","(","add",",","'","x","'",",","0",")",",","'","x","'",",","(","'","x","'",",",")",")",",","...","RewriteRule","(","(","f",",","(","g",",","'","x","'",")",",","'","y","'",")",",","...","(","h",",","'","x","'",",","'","y","'",")",",","...","(","'","x","'",",","'","y","'",")",")",")",">",">",">","rs.rewrite","(","(","add",",","2",",","0",")",")","#","Apply","ruleset","to","single","task","2",">",">",">","rs.rewrite","(","(","f",",","(","g",",","'","a","'",",","3",")",")",")","#","doctest",":","+ELLIPSIS","(","<","function","h","at","...",">",",","'","a","'",",","3",")",">",">",">","dsk","=","{","'","a","'",":","(","add",",","2",",","0",")",",","#","Apply","ruleset","to","full","dask","graph","...","'","b","'",":","(","f",",","(","g",",","'","a","'",",","3",")",")","}","Attributes","--","--","--","--","--","rules",":","list","A","list","of","`","RewriteRule","`","s","included","in","the","`","RuleSet","`","."]
docstr: A generator that lazily finds matchings for term from the RuleSet.
  
  Parameters
  ----------
  term : task
  
  Yields
  ------
  Tuples of `(rule, subs)`, where `rule` is the rewrite rule being
  matched, and `subs` is a dictionary mapping the variables in the lhs
  of the rule to their matching values in the term.
docstr_tok: ["A","generator","that","lazily","finds","matchings","for","term","from","the","RuleSet",".","Parameters","--","--","--","--","--","term",":","task","Yields","--","--","--","Tuples","of","`","(","rule",",","subs",")","`",",","where","`","rule","`","is","the","rewrite","rule","being","matched",",","and","`","subs","`","is","a","dictionary","mapping","the","variables","in","the","lhs","of","the","rule","to","their","matching","values","in","the","term","."]
code: def iter_matches(self, term):
      """A generator that lazily finds matchings for term from the RuleSet.
  
      Parameters
      ----------
      term : task
  
      Yields
      ------
      Tuples of `(rule, subs)`, where `rule` is the rewrite rule being
      matched, and `subs` is a dictionary mapping the variables in the lhs
      of the rule to their matching values in the term.
  
      """
  
      S = Traverser(term)
      for m, syms in _match(S, self._net):
          for i in m:
              rule = self.rules[i]
              subs = _process_match(rule, syms)
              if subs is not None:
                  yield rule, subs
  
imports: from collections import deque
  from flash.core.serve.dag.task import istask, subs
  from flash.core.utilities.imports import _TOPIC_SERVE_AVAILABLE
label_desc: Use image node_id 3 for calling the RuleSet obj's underlying member method code with example usage: obj.iter_matches(term) without return types