class_docstr: Captures a hand-selected set of (global) variables in modules and provides a way to restore them.
  
  It facilitates and encapsulates the transfer of globals like PyTorch's deterministic flags or random generator state
  across process boundaries when launching processes with :func:`torch.multiprocessing.spawn`.
  
  Example:
  
      .. code-block:: python
  
          # in main process
          snapshot = _GlobalStateSnapshot.capture()
  
          # in worker process
          snapshot.restore()
docstr: Restores all globals to the values captured in the :meth:`capture` method.
docstr_tok: ["Restores","all","globals","to","the","values","captured","in","the",":","meth",":","`","capture","`","method","."]
code: def restore(self) -> None:
      """Restores all globals to the values captured in the :meth:`capture` method."""
      torch.use_deterministic_algorithms(
          self.use_deterministic_algorithms,
          warn_only=self.use_deterministic_algorithms_warn_only,
      )
      torch.backends.cudnn.benchmark = self.cudnn_benchmark
      _set_rng_states(self.rng_states)
  
imports: import itertools
  import os
  from dataclasses import dataclass
  from multiprocessing.queues import SimpleQueue
  from textwrap import dedent
  from typing import TYPE_CHECKING, Any, Callable, Dict, Literal, Optional
  import torch
  import torch.backends.cudnn
  import torch.multiprocessing
  from lightning_utilities import apply_to_collection
  from torch.nn import Module
  from typing_extensions import override
  from lightning.fabric.accelerators.cpu import CPUAccelerator
  from lightning.fabric.strategies.launchers.launcher import _Launcher
  from lightning.fabric.utilities.apply_func import move_data_to_device
  from lightning.fabric.utilities.distributed import _set_num_threads_if_needed
  from lightning.fabric.utilities.imports import _IS_INTERACTIVE
  from lightning.fabric.utilities.seed import _collect_rng_states, _set_rng_states
label_desc: Use image node_id 2 for calling the _GlobalStateSnapshot obj's underlying member method code with example usage: obj.restore() without return types