def check_random_state(seed):
if seed is None or seed is np.random:<EOL><INDENT>return np.random.mtrand._rand<EOL><DEDENT>if isinstance(seed, (numbers.Integral, np.integer)):<EOL><INDENT>return np.random.RandomState(seed)<EOL><DEDENT>if isinstance(seed, np.random.RandomState):<EOL><INDENT>return seed<EOL><DEDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % seed)<EOL>
Turn seed into a np.random.RandomState instance
    If seed is None, return the RandomState singleton used by np.random.
    If seed is an int, return a new RandomState instance seeded with seed.
    If seed is already a RandomState instance, return it.
    Otherwise raise ValueError.