code: def _get_rng(random_state):
      """Get a random number generator (RandomState) object
      from a seed or existing state.
  
      Parameters
      ----------
      random_state : None, int, or np.random.RandomState
          If int, random_state is the seed used by the random number generator;
  
          If RandomState instance, random_state is the random number generator;
  
          If None, the random number generator is a copy of the current global
          random state.
  
      Returns
      -------
      rng : np.random.RandomState
          The RandomState object
      """
      if random_state is None:
          state = np.random.get_state()
          rng = np.random.RandomState()
          rng.set_state(state)
      elif isinstance(random_state, int):
          rng = np.random.RandomState(seed=random_state)
      elif isinstance(random_state, np.random.RandomState):
          rng = random_state
      else:
          raise ValueError(
              "Invalid random_state={}".format(random_state)
          )
  
      return rng
  
imports: import numpy
  import copy
  from collections import OrderedDict
  import itertools
  import six
  import inspect
label_desc: Use image node_id 2 for calling a global function with example usage: _get_rng(random_state) and returns: rng