class_docstr: A rewrite rule.
  
  Expresses `lhs` -> `rhs`, for variables `vars`.
  
  Parameters
  ----------
  lhs : task
      The left-hand-side of the rewrite rule.
  rhs : task or function
      The right-hand-side of the rewrite rule. If it's a task, variables in
      `rhs` will be replaced by terms in the subject that match the variables
      in `lhs`. If it's a function, the function will be called with a dict
      of such matches.
  vars: tuple, optional
      Tuple of variables found in the lhs. Variables can be represented as
      any hashable object; a good convention is to use strings. If there are
      no variables, this can be omitted.
  
  Examples
  --------
  Here's a `RewriteRule` to replace all nested calls to `list`, so that
  `(list, (list, 'x'))` is replaced with `(list, 'x')`, where `'x'` is a
  variable.
  
  >>> lhs = (list, (list, 'x'))
  >>> rhs = (list, 'x')
  >>> variables = ('x',)
  >>> rule = RewriteRule(lhs, rhs, variables)
  
  Here's a more complicated rule that uses a callable right-hand-side. A
  callable `rhs` takes in a dictionary mapping variables to their matching
  values. This rule replaces all occurrences of `(list, 'x')` with `'x'` if
  `'x'` is a list itself.
  
  >>> lhs = (list, 'x')
  >>> def repl_list(sd):
  ...     x = sd['x']
  ...     if isinstance(x, list):
  ...         return x
  ...     else:
  ...         return list, x
  >>> rule = RewriteRule(lhs, repl_list, variables)
class_docstr_tok: ["A","rewrite","rule",".","Expresses","`","lhs","`","-",">","`","rhs","`",",","for","variables","`","vars","`",".","Parameters","--","--","--","--","--","lhs",":","task","The","left-hand-side","of","the","rewrite","rule",".","rhs",":","task","or","function","The","right-hand-side","of","the","rewrite","rule",".","If","it","'s","a","task",",","variables","in","`","rhs","`","will","be","replaced","by","terms","in","the","subject","that","match","the","variables","in","`","lhs","`",".","If","it","'s","a","function",",","the","function","will","be","called","with","a","dict","of","such","matches",".","vars",":","tuple",",","optional","Tuple","of","variables","found","in","the","lhs",".","Variables","can","be","represented","as","any","hashable","object",";","a","good","convention","is","to","use","strings",".","If","there","are","no","variables",",","this","can","be","omitted",".","Examples","--","--","--","--","Here","'s","a","`","RewriteRule","`","to","replace","all","nested","calls","to","`","list","`",",","so","that","`","(","list",",","(","list",",","'","x","'",")",")","`","is","replaced","with","`","(","list",",","'","x","'",")","`",",","where","`","'","x","'","`","is","a","variable",".",">",">",">","lhs","=","(","list",",","(","list",",","'","x","'",")",")",">",">",">","rhs","=","(","list",",","'","x","'",")",">",">",">","variables","=","(","'","x","'",",",")",">",">",">","rule","=","RewriteRule","(","lhs",",","rhs",",","variables",")","Here","'s","a","more","complicated","rule","that","uses","a","callable","right-hand-side",".","A","callable","`","rhs","`","takes","in","a","dictionary","mapping","variables","to","their","matching","values",".","This","rule","replaces","all","occurrences","of","`","(","list",",","'","x","'",")","`","with","`","'","x","'","`","if","`","'","x","'","`","is","a","list","itself",".",">",">",">","lhs","=","(","list",",","'","x","'",")",">",">",">","def","repl_list","(","sd",")",":","...","x","=","sd","[","'","x","'","]","...","if","isinstance","(","x",",","list",")",":","...","return","x","...","else",":","...","return","list",",","x",">",">",">","rule","=","RewriteRule","(","lhs",",","repl_list",",","variables",")"]
code: def __repr__(self):
      return str(self)
  
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 4 for calling the RewriteRule obj's underlying member method code with example usage: obj.__repr__() and returns: str