'Eject selected generators into the ground domain.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x, y
>>> f = Poly(x**2*y + x*y**3 + x*y + 1, x, y)
>>> f.eject(x)
Poly(x*y**3 + (x**2 + x)*y + 1, y, domain=\'ZZ[x]\')
>>> f.eject(y)
Poly(y*x**2 + (y**3 + y)*x + 1, x, domain=\'ZZ[y]\')'

def eject(f, *gens):

    dom = f.rep.dom
    if (not dom.is_Numerical):
        raise DomainError(("can't    eject    generators    over    %s" % dom))
    (n, k) = (len(f.gens), len(gens))
    if (f.gens[:k] == gens):
        (_gens, front) = (f.gens[k:], True)
    elif (f.gens[(- k):] == gens):
        (_gens, front) = (f.gens[:(- k)], False)
    else:
        raise NotImplementedError('can    only    eject    front    or    back    generators')
    dom = dom.inject(*gens)
    if hasattr(f.rep, 'eject'):
        result = f.rep.eject(dom, front=front)
    else:
        raise OperationNotSupported(f, 'eject')
    return f.new(result, *_gens)
