code: def test_matches():
      term = (add, 2, 1)
      matches = list(rs.iter_matches(term))
      assert len(matches) == 1
      assert matches[0] == (rule1, {"a": 2})
      # Test matches specific before general
      term = (add, 1, 1)
      matches = list(rs.iter_matches(term))
      assert len(matches) == 2
      assert matches[0] == (rule1, {"a": 1})
      assert matches[1] == (rule2, {"a": 1})
      # Test matches unhashable. What it's getting rewritten to doesn't make
      # sense, this is just to test that it works. :)
      term = (add, [1], [1])
      matches = list(rs.iter_matches(term))
      assert len(matches) == 1
      assert matches[0] == (rule2, {"a": [1]})
      # Test match at depth
      term = (add, (inc, 1), (inc, 1))
      matches = list(rs.iter_matches(term))
      assert len(matches) == 3
      assert matches[0] == (rule3, {"a": 1})
      assert matches[1] == (rule4, {"a": 1, "b": 1})
      assert matches[2] == (rule2, {"a": (inc, 1)})
      # Test non-linear pattern checking
      term = (add, 2, 3)
      matches = list(rs.iter_matches(term))
      assert len(matches) == 0
  
file_path: dask/dask/tests/test_rewrite.py
imports: from __future__ import annotations
  from dask.rewrite import VAR, RewriteRule, RuleSet, Traverser, args, head
  from dask.utils_test import add, inc
label_desc: Use image node_id 9 for calling a global function with example usage: test_matches() without return types