human
I wrote the below code

    from sympy.matrices.expressions import MatAdd, MatMul, MatPow
    opt_subs = dict()
    adds = set()
    muls = set()
    seen_subexp = set()
    def _find_opts(expr):
        if (not isinstance(expr, Basic)):
            return
        if (expr.is_Atom or expr.is_Order):
            return
        if iterable(expr):
            list(map(_find_opts, expr))
            return
        if (expr in seen_subexp):
            return expr
        seen_subexp.add(expr)
        list(map(_find_opts, expr.args))
        if _coeff_isneg(expr):
            neg_expr = (- expr)
            if (not neg_expr.is_Atom):
                opt_subs[expr] = Mul(S.NegativeOne, neg_expr, evaluate=False)
                seen_subexp.add(neg_expr)
                expr = neg_expr
        if isinstance(expr, (Mul, MatMul)):
            muls.add(expr)
        elif isinstance(expr, (Add, MatAdd)):
            adds.add(expr)
        elif isinstance(expr, (Pow, MatPow)):
            if _coeff_isneg(expr.exp):
                opt_subs[expr] = Pow(Pow(expr.base, (- expr.exp)), S.NegativeOne, evaluate=False)
    for e in exprs:
        if isinstance(e, Basic):
            _find_opts(e)
    def _match_common_args(Func, funcs):
        if (order != 'none'):
            funcs = list(ordered(funcs))
        else:
            funcs = sorted(funcs, key=(lambda x: len(x.args)))
        func_args = [set(e.args) for e in funcs]
        for i in range(len(func_args)):
            for j in range((i + 1), len(func_args)):
                com_args = func_args[i].intersection(func_args[j])
                if (len(com_args) > 1):
                    com_func = Func(*com_args)
                    diff_i = func_args[i].difference(com_args)
                    func_args[i] = (diff_i | {com_func})
                    if diff_i:
                        opt_subs[funcs[i]] = Func(Func(*diff_i), com_func, evaluate=False)
                    diff_j = func_args[j].difference(com_args)
                    func_args[j] = (diff_j | {com_func})
                   ...

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def opt_cse(exprs, order='canonical'):