def _guess_variables(polynomial, *args):
    """
    Return the polynomial variables

    INPUT:

    - ``polynomial`` -- a polynomial.

    - ``*args`` -- the variables. If none are specified, all variables
      in ``polynomial`` are returned. If a list or tuple is passed,
      the content is returned. If multiple arguments are passed, they
      are returned.

    OUTPUT:

    A tuple of variables in the parent ring of the polynoimal.

    EXAMPLES::

       sage: from sage.rings.invariant_theory import _guess_variables
       sage: R.<x,y> = QQ[]
       sage: _guess_variables(x^2+y^2)
       (x, y)
       sage: _guess_variables(x^2+y^2, x)
       (x,)
       sage: _guess_variables(x^2+y^2, x,y)
       (x, y)
       sage: _guess_variables(x^2+y^2, [x,y])
       (x, y)
    """
    if len(args)==0 or (len(args)==1 and args[0] is None):
        return polynomial.variables()
    elif len(args) == 1 and isinstance(args[0], (tuple, list)):
        return tuple(args[0])
    else:
        return tuple(args)