(self)
| 16 | ] |
| 17 | |
| 18 | def restore(self): |
| 19 | random.setstate(self.random_mod_state) |
| 20 | np.random.set_state(self.np_state) |
| 21 | torch.set_rng_state(self.torch_cpu_state) |
| 22 | for d, state in enumerate(self.torch_gpu_states): |
| 23 | torch.cuda.set_rng_state(state, d) |
| 24 | |
| 25 | |
| 26 | class RandomContext: |