code: def unify(x, y, s=None, **fns):
      """Unify two expressions.
  
      Parameters
      ==========
  
          x, y - expression trees containing leaves, Compounds and Variables.
          s    - a mapping of variables to subtrees.
  
      Returns
      =======
  
          lazy sequence of mappings {Variable: subtree}
  
      Examples
      ========
  
      >>> from sympy.unify.core import unify, Compound, Variable
      >>> expr    = Compound("Add", ("x", "y"))
      >>> pattern = Compound("Add", ("x", Variable("a")))
      >>> next(unify(expr, pattern, {}))
      {Variable(a): 'y'}
      """
      s = s or {}
  
      if x == y:
          yield s
      elif isinstance(x, (Variable, CondVariable)):
          yield from unify_var(x, y, s, **fns)
      elif isinstance(y, (Variable, CondVariable)):
          yield from unify_var(y, x, s, **fns)
      elif isinstance(x, Compound) and isinstance(y, Compound):
          is_commutative = fns.get("is_commutative", lambda x: False)
          is_associative = fns.get("is_associative", lambda x: False)
          for sop in unify(x.op, y.op, s, **fns):
              if is_associative(x) and is_associative(y):
                  a, b = (x, y) if len(x.args) < len(y.args) else (y, x)
                  if is_commutative(x) and is_commutative(y):
                      combs = allcombinations(
                          a.args, b.args, "commutative"
                      )
                  else:
                      combs = allcombinations(
                          a.args, b.args, "associative"
                      )
                  for aaargs, bbargs in combs:
                      aa = [
                          unpack(Compound(a.op, arg)) for arg in aaargs
                      ]
                      bb = [
                          unpack(Compound(b.op, arg)) for arg in bbargs
                      ]
                      yield from unify(aa, bb, sop, **fns)
              elif len(x.args) == len(y.args):
                  yield from unify(x.args, y.args, sop, **fns)
  
      elif is_args(x) and is_args(y) and len(x) == len(y):
          if len(x) == 0:
              yield s
          else:
              for shead in unify(x[0], y[0], s, **fns):
                  yield from unify(x[1:], y[1:], shead, **fns)
  
imports: from sympy.utilities.iterables import kbins
label_desc: Use image node_id 1 for calling a global function with example usage: unify(x, y, s) without return types