class_docstr: Immutable dataclass that holds the state of the various random number generators.
class_docstr_tok: ["Immutable","dataclass","that","holds","the","state","of","the","various","random","number","generators","."]
docstr: Seeds all the RNGs using the given seed, and returns the resulting RandomState object.
docstr_tok: ["Seeds","all","the","RNGs","using","the","given","seed",",","and","returns","the","resulting","RandomState","object","."]
code: def seed(cls, base_seed: int | None) -> RandomState:
      """Seeds all the RNGs using the given seed, and returns the resulting RandomState object."""
      random.seed(base_seed)
      numpy_seed = random.randint(0, 2**32 - 1)
      # NOTE: Always create the torch seed, even if torch is not installed.
      torch_seed = random.randint(0, 2**32 - 1)
      np.random.seed(numpy_seed)
      if TORCH_INSTALLED:
          torch.random.manual_seed(torch_seed)
          torch.cuda.manual_seed_all(torch_seed)
  
      random_state = cls.current()
      if base_seed is not None:
          # Add the base_seed property in this case.
          random_state = replace(random_state, base_seed=base_seed)
      return random_state
  
file_path: orion/src/orion/core/utils/random_state.py
imports: from __future__ import annotations
  import random
  from contextlib import contextmanager
  from dataclasses import dataclass, replace
  from typing import Any, Protocol
  import numpy
label_desc: Use image node_id 3 for calling the RandomState obj's underlying member method code with example usage: obj.seed(cls, base_seed) and returns: random_state