def expr_from_dict(rep, *gens):
    result = []

    for monom, coeff in rep.items():
        term = [coeff]
        for g, m in zip(gens, monom):
            if m:
                term.append(Pow(g, m))

        result.append(Mul(*term))

    return Add(*result)
Convert a multinomial form into an expression.
dataset/ETHPy150Open sympy/sympy/sympy/polys/polyutils.py/expr_from_dict