code: def ensure_rng(random_state=None):
      """
      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 = np.random.RandomState()
      elif isinstance(random_state, int):
          random_state = np.random.RandomState(random_state)
      else:
          assert isinstance(random_state, np.random.RandomState)
      return random_state
  
imports: import warnings
  import numpy
  from scipy.stats import norm
  from scipy.optimize import minimize
  from colorama import just_fix_windows_console
  import json
label_desc: Use image node_id 3 for calling a global function with example usage: ensure_rng(random_state) and returns: random_state