code: def ensure_rng(random_state) -> RandomState:
      """
      Creates a random number generator based on an optional seed.  This can be
      an integer or another random state for a seeded rng, or None for an
      unseeded rng.
      """
      if random_state is None:
          random_state = RandomState()
      elif isinstance(random_state, int):
          random_state = RandomState(random_state)
      else:
          assert isinstance(random_state, RandomState)
      return random_state
  
imports: from .compat import pd_DataFrame, pd_Series, pd_read_parquet
  import numpy
  from numpy.random import RandomState
  import blosc
  import dill
  from typing import Union, List, Dict, Optional
label_desc: Use image node_id 8 for calling a global function with example usage: ensure_rng(random_state) and returns: random_state