import sympy


def round_sympy_expr(expr, decimals):
    """Returns the expression with every float rounded to the given number of decimals."""
    rounded_expr = expr
    for a in sympy.preorder_traversal(expr):
        if isinstance(a, sympy.Float):
            rounded_expr = rounded_expr.subs(a, round(a, decimals))
    return rounded_expr