<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_eigen_solver(eigen_solver, solver_kwds, size=None, nvec=None):
 """Check that the selected eigensolver is valid Parameters eigen_solver : string string value to validate size, nvec : int (optional) if both provided, use the specified problem size and number of vectors to determine the optimal method to use with eigen_solver='auto' Returns ------- eigen_solver : string The eigen solver. This only differs from the input if eigen_solver == 'auto' and `size` is specified. """

    if eigen_solver in BAD_EIGEN_SOLVERS:
        raise ValueError(BAD_EIGEN_SOLVERS[eigen_solver])
    elif eigen_solver not in EIGEN_SOLVERS:
        raise ValueError("Unrecognized eigen_solver: '{0}'."
                         "Should be one of: {1}".format(eigen_solver,
                                                        EIGEN_SOLVERS))

    if size is not None and nvec is not None:
        # do some checks of the eigensolver
        if eigen_solver == 'lobpcg' and size < 5 * nvec + 1:
            warnings.warn("lobpcg does not perform well with small matrices or "
                          "with large numbers of vectors. Switching to 'dense'")
            eigen_solver = 'dense'
            solver_kwds = None

        elif eigen_solver == 'auto':
            if size > 200 and nvec < 10:
                if PYAMG_LOADED:
                    eigen_solver = 'amg'
                    solver_kwds = None
                else:
                    eigen_solver = 'arpack'
                    solver_kwds = None
            else:
                eigen_solver = 'dense'
                solver_kwds = None

    return eigen_solver, solver_kwds