# Generator Source: https://www.tensorplay.cn/docs/generated/tensorplay.Generator.html ```python class tensorplay.Generator(device='cpu') → Generator ``` Creates and returns a generator object that manages the state of the algorithm which produces pseudo random numbers. Used as a keyword argument in many in-place random sampling functions. Parameters: device ([tensorplay.device](/docs/generated/tensorplay.Device.html#tensorplay.Device), optional) – the desired device for the generator. Returns: An tensorplay.Generator object. Return type: [Generator](#tensorplay.Generator) Example: ``` >>> g_cpu = tensorplay.Generator() >>> g_cuda = tensorplay.Generator(device='cuda') ``` ```python property device ``` Generator.device -> device Gets the current device of the generator. Example: ``` >>> g_cpu = tensorplay.Generator() >>> g_cpu.device device(type='cpu') ``` ```python get_state(self: tensorplay._C.Generator) → tensorplay::Tensor ``` ```python initial_seed(self: tensorplay._C.Generator) → int ``` ```python manual_seed(self: tensorplay._C.Generator, seed: SupportsInt | SupportsIndex) → int ``` ```python seed(self: tensorplay._C.Generator) → int ``` ```python set_state(self: tensorplay._C.Generator, new_state: tensorplay::Tensor) → None ```