Returns: int: a random number that is the same across all workers. If workers need a shared RNG, they can use this shared seed to create one. All workers must call this function, otherwise it will deadlock.
()
| 236 | |
| 237 | |
| 238 | def shared_random_seed(): |
| 239 | """ |
| 240 | Returns: |
| 241 | int: a random number that is the same across all workers. |
| 242 | If workers need a shared RNG, they can use this shared seed to |
| 243 | create one. |
| 244 | All workers must call this function, otherwise it will deadlock. |
| 245 | """ |
| 246 | ints = np.random.randint(2 ** 31) |
| 247 | all_ints = all_gather(ints) |
| 248 | return all_ints[0] |
| 249 | |
| 250 | |
| 251 | def time_synchronized(): |
nothing calls this directly
no test coverage detected