code: def derivable_rng(spec):
      """
      Get a derivable RNG, for use cases where the code needs to be able to reproducibly derive
      sub-RNGs for different keys, such as user IDs.
  
      Args:
          spec:
              Any value supported by the `seed` parameter of :func:`seedbank.numpy_rng`, in addition
              to the following values:
  
              * the string ``'user'``
              * a tuple of the form (``seed``, ``'user'``)
  
              Either of these forms will cause the returned function to re-derive new RNGs.
  
      Returns:
          function:
              A function taking one (or more) key values, like :func:`derive_seed`, and
              returning a random number generator.
      """
  
      if spec == "user":
          return DerivingRNG(seedbank.derive_seed())
      elif isinstance(spec, tuple):
          seed, key = spec
          if key != "user":
              raise ValueError("unrecognized key %s", key)
          return DerivingRNG(seed)
      else:
          return FixedRNG(seedbank.numpy_rng(spec))
  
file_path: lkpy/lenskit/util/random.py
imports: import numpy
  import seedbank
label_desc: Use image node_id 1 for calling a global function with example usage: derivable_rng(spec) and returns: DerivingRNG, DerivingRNG, FixedRNG