def _check_engine(engine):
from pandas.core.computation.check import _NUMEXPR_INSTALLED<EOL>if engine is None:<EOL><INDENT>if _NUMEXPR_INSTALLED:<EOL><INDENT>engine = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>engine = '<STR_LIT>'<EOL><DEDENT><DEDENT>if engine not in _engines:<EOL><INDENT>valid = list(_engines.keys())<EOL>raise KeyError('<STR_LIT>'<EOL>'<STR_LIT>'.format(engine=engine, valid=valid))<EOL><DEDENT>if engine == '<STR_LIT>':<EOL><INDENT>if not _NUMEXPR_INSTALLED:<EOL><INDENT>raise ImportError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>return engine<EOL>
Make sure a valid engine is passed.

    Parameters
    ----------
    engine : str

    Raises
    ------
    KeyError
      * If an invalid engine is passed
    ImportError
      * If numexpr was requested but doesn't exist

    Returns
    -------
    string engine