code: def check_random_state(seed):
      """Turn seed into a numpy.random.mtrand.RandomState instance.
  
      If seed is None, return the RandomState singleton used by np.random.mtrand.
      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.
      """
      if seed is None or seed is np.random:
          return np.random.mtrand._rand
      if isinstance(seed, (int, np.integer)):
          return np.random.mtrand.RandomState(seed)
      if isinstance(seed, np.random.mtrand.RandomState):
          return seed
      try:
          # Generator is only available in numpy >= 1.17
          if isinstance(seed, np.random.Generator):
              return seed
      except AttributeError:
          pass
      raise ValueError(
          "%r cannot be used to seed a "
          "numpy.random.mtrand.RandomState instance" % seed
      )
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 10 for calling a global function with example usage: check_random_state(seed) and returns: np, np, seed, seed