class_docstr: A class used to manage a set of deterministic random number generators.
  
  The main goal of this class is to provide a simplified mechanism to
  improve determinism on the RNG side. This class includes a method to set
  a manual seed of all number generators and a method to register new
  generators.
  
  By default, Python (`random` module), NumPy, and PyTorch global generators
  are managed.
class_docstr_tok: ["A","class","used","to","manage","a","set","of","deterministic","random","number","generators",".","The","main","goal","of","this","class","is","to","provide","a","simplified","mechanism","to","improve","determinism","on","the","RNG","side",".","This","class","includes","a","method","to","set","a","manual","seed","of","all","number","generators","and","a","method","to","register","new","generators",".","By","default",",","Python","(","`","random","`","module",")",",","NumPy",",","and","PyTorch","global","generators","are","managed","."]
docstr: Register a new random number generator.
  
  Please note that Python's `random`, NumPy, and PyTorch global generators
  are already supported out-of-the-box and should not be re-registered.
  
  :param name: The name of the random number generator.
  :param rng_def: The definition of the random number generator.
      This must be a dictionary including the following fields:
      `seed`: a function that initializes the internal random
      number generator, it should accept an int (the seed);
      `save_state`: a function that returns an object that can be used to
      restore the state of the random number generator. The returned
      object should be pickleable; `load_state`: a function that sets
      the internal state of the  generator based on the object passed as
      an argument. That object is the one returned from a previous call to
      `save_state`; `step`: a function that advances the state of the
      random number generator. Its return value is ignored. To advance the
      state, it is recommended to generate a small amount of random
      data, like a float (to minimize the performance impact).
docstr_tok: ["Register","a","new","random","number","generator",".","Please","note","that","Python","'s","`","random","`",",","NumPy",",","and","PyTorch","global","generators","are","already","supported","out-of-the-box","and","should","not","be","re-registered",".",":","param","name",":","The","name","of","the","random","number","generator",".",":","param","rng_def",":","The","definition","of","the","random","number","generator",".","This","must","be","a","dictionary","including","the","following","fields",":","`","seed","`",":","a","function","that","initializes","the","internal","random","number","generator",",","it","should","accept","an","int","(","the","seed",")",";","`","save_state","`",":","a","function","that","returns","an","object","that","can","be","used","to","restore","the","state","of","the","random","number","generator",".","The","returned","object","should","be","pickleable",";","`","load_state","`",":","a","function","that","sets","the","internal","state","of","the","generator","based","on","the","object","passed","as","an","argument",".","That","object","is","the","one","returned","from","a","previous","call","to","`","save_state","`",";","`","step","`",":","a","function","that","advances","the","state","of","the","random","number","generator",".","Its","return","value","is","ignored",".","To","advance","the","state",",","it","is","recommended","to","generate","a","small","amount","of","random","data",",","like","a","float","(","to","minimize","the","performance","impact",")","."]
code: def register_random_generator(self, name: str, rng_def: dict):
      """
      Register a new random number generator.
  
      Please note that Python's `random`, NumPy, and PyTorch global generators
      are already supported out-of-the-box and should not be re-registered.
  
      :param name: The name of the random number generator.
      :param rng_def: The definition of the random number generator.
          This must be a dictionary including the following fields:
          `seed`: a function that initializes the internal random
          number generator, it should accept an int (the seed);
          `save_state`: a function that returns an object that can be used to
          restore the state of the random number generator. The returned
          object should be pickleable; `load_state`: a function that sets
          the internal state of the  generator based on the object passed as
          an argument. That object is the one returned from a previous call to
          `save_state`; `step`: a function that advances the state of the
          random number generator. Its return value is ignored. To advance the
          state, it is recommended to generate a small amount of random
          data, like a float (to minimize the performance impact).
      """
      rng_def_keys = set(rng_def.keys())
      if not rng_def_keys.issubset(_RNGManager.RNG_DEF_REQUIRED_FIELDS):
          raise ValueError("Invalid random number generator definition")
  
      self.random_generators[name] = rng_def
  
file_path: avalanche/avalanche/training/determinism/rng_manager.py
imports: import random
  from collections import OrderedDict
  from typing import Any, Dict, Type
  import numpy
  import torch
  from avalanche.training.determinism.cuda_rng import cuda_rng_seed, cuda_rng_save_state, cuda_rng_load_state, cuda_rng_step, cpu_rng_seed
label_desc: Use image node_id 2 for calling the _RNGManager obj's underlying member method code with example usage: obj.register_random_generator(name, rng_def) without return types