code: def check_random_state(random_state):
      """Validate the random state, r
  
      Check a random seed or existing numpy RandomState
      and get back an initialized RandomState.
  
      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 curand RandomState generator
      """
      if isinstance(random_state, np.random.RandomState):
          # we need to convert from numpy random state our internal random state
          return implicit.gpu.RandomState(random_state.randint(2**31))
  
      if isinstance(random_state, np.random.Generator):
          # we need to convert from numpy random state our internal random state
          return implicit.gpu.RandomState(
              random_state.integers(2**31)
          )
  
      # otherwise try to initialize a new one, and let it fail through
      # on the numpy side if it doesn't work
      return implicit.gpu.RandomState(random_state or int(time.time()))
  
imports: import time
  import numpy
  from scipy.sparse import csr_matrix
  import implicit.gpu
  from ..cpu.matrix_factorization_base import _filter_items_from_sparse_matrix
  from ..recommender_base import RecommenderBase
label_desc: Use image node_id 1 for calling a global function with example usage: check_random_state(random_state) and returns: implicit, implicit, implicit