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: Create a `RuleSet` for a number of rules.
  
  Parameters
  ----------
  rules
      One or more instances of RewriteRule
docstr_tok: ["Create","a","`","RuleSet","`","for","a","number","of","rules",".","Parameters","--","--","--","--","--","rules","One","or","more","instances","of","RewriteRule"]
code: def __init__(self, *rules):
      """Create a `RuleSet` for a number of rules.
  
      Parameters
      ----------
      rules
          One or more instances of RewriteRule
  
      """
      self._net = Node()
      self.rules = []
      for p in rules:
          self.add(p)
  
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 1 to create a new RuleSet object  with example: obj = RuleSet()