def __setstate__(self, state): self.__dict__ = state random.setstate(state.pop('_random_state')) np.random.set_state(state.pop('_np_random_state'))