'Create a Poly out of the given representation.
Examples
>>> from sympy import Poly, ZZ
>>> from sympy.abc import x, y
>>> from sympy.polys.polyclasses import DMP
>>> a = Poly(x**2 + 1)
>>> a.per(DMP([ZZ(1), ZZ(1)], ZZ), gens=[y])
Poly(y + 1, y, domain=\'ZZ\')'

def per(f, rep, gens=None, remove=None):

    if (gens is None):
        gens = f.gens
    if (remove is not None):
        gens = (gens[:remove] + gens[(remove + 1):])
        if (not gens):
            return f.rep.dom.to_sympy(rep)
    return f.__class__.new(rep, *gens)
