latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.random.thread_safe_generator
- tensorplay.random.thread_safe_generator()[source]
Returns a thread-safe random number generator for use in DataLoader workers.
This function provides a convenient way for transforms and user code to use thread-safe random number generation without manually checking worker context.
When called in a DataLoader thread worker, returns the worker’s thread-local
tensorplay.Generator. When called in the main process or process workers, returnsNone(which causes operations to use the default global RNG).Example
>>> from tensorplay.random import thread_safe_generator >>> generator = thread_safe_generator() >>> tensorplay.randint(0, 10, (5,), generator=generator)
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

