code: def check_random_state(seed=None):
      """Turn `seed` into a `numpy.random.Generator` instance.
      Parameters
      ----------
      seed : {None, int, Generator, RandomState}, optional
          If `seed` is None (or `np.random`), the `numpy.random.RandomState`
          singleton is used.
          If `seed` is an int, a new ``numpy.random.RandomState`` instance
          is used, seeded with `seed`.
          If `seed` is already a ``numpy.random.Generator`` or
          ``numpy.random.RandomState`` instance then that instance is used.
      Returns
      -------
      seed : {`numpy.random.Generator`, `numpy.random.RandomState`}
          Random number generator.
      """
      if seed is None or isinstance(
          seed, (numbers.Integral, np.integer)
      ):
          return np.random.default_rng(seed)
      elif isinstance(
          seed, (np.random.RandomState, np.random.Generator)
      ):
          return seed
      else:
          raise ValueError(
              f"{seed!r} cannot be used to seed a"
              " numpy.random.Generator instance"
          )
  
imports: import numbers
  import warnings
  import numpy
  from .kalman_smoother import KalmanSmoother
  from .cfa_simulation_smoother import CFASimulationSmoother
  from .None import tools
label_desc: Use image node_id 1 for calling a global function with example usage: check_random_state(seed) and returns: np, seed