code: def check_random_state(random_state):
      """Validate the random state.
  
      Check a random seed or existing numpy rng
      and get back an initialized numpy.randon.Generator
  
      Parameters
      ----------
      random_state : int, None, np.random.RandomState or np.random.Generator
          The existing RandomState. If None, or an int, will be used
          to seed a new numpy RandomState.
      """
      # backwards compatibility
      if isinstance(random_state, np.random.RandomState):
          return np.random.default_rng(random_state.rand_int(2**31))
  
      # otherwise try to initialize a new one, and let it fail through
      # on the numpy side if it doesn't work
      return np.random.default_rng(random_state)
  
file_path: implicit/implicit/utils.py
imports: import time
  import warnings
  import numpy
  import scipy.sparse
  import threadpoolctl
label_desc: Use image node_id 3 for calling a global function with example usage: check_random_state(random_state) and returns: np, np