code: def check_random_state(seed):
      """Turn `seed` into a `np.random.RandomState` instance.
  
      Parameters
      ----------
      seed : {None, int, `numpy.random.Generator`,
              `numpy.random.RandomState`}, optional
  
          If `seed` is None (or `np.random`), the `numpy.random.RandomState`
          singleton is used.
          If `seed` is an int, a new ``RandomState`` instance is used,
          seeded with `seed`.
          If `seed` is already a ``Generator`` or ``RandomState`` instance then
          that instance is used.
  
      Returns
      -------
      seed : {`numpy.random.Generator`, `numpy.random.RandomState`}
          Random number generator.
  
      """
      if seed is None or seed is np.random:
          return np.random.mtrand._rand
      if isinstance(seed, (numbers.Integral, np.integer)):
          return np.random.RandomState(seed)
      if isinstance(seed, np.random.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.RandomState"
          " instance" % seed
      )
  
imports: from contextlib import contextmanager
  import functools
  import operator
  import sys
  import warnings
  import numbers
  from collections import namedtuple
  import inspect
  import math
  from typing import Optional, Union, TYPE_CHECKING, TypeVar
  import numpy
label_desc: Use image node_id 7 for calling a global function with example usage: check_random_state(seed) and returns: np, np, seed, seed