code: def test_global_state_snapshot():
      """Test the capture() and restore() methods for the global state snapshot."""
      torch.use_deterministic_algorithms(True)
      torch.backends.cudnn.benchmark = False
      torch.manual_seed(123)
  
      # capture the state of globals
      snapshot = _GlobalStateSnapshot.capture()
  
      # simulate there is a process boundary and flags get reset here
      torch.use_deterministic_algorithms(False)
      torch.backends.cudnn.benchmark = True
      torch.manual_seed(321)
  
      # restore the state of globals
      snapshot.restore()
      assert torch.are_deterministic_algorithms_enabled()
      assert not torch.backends.cudnn.benchmark
      assert torch.initial_seed() == 123
  
file_path: pytorch-lightning/tests/tests_fabric/strategies/launchers/test_multiprocessing.py
imports: from unittest import mock
  from unittest.mock import ANY, Mock
  import pytest
  import torch
  from lightning.fabric.strategies.launchers.multiprocessing import _GlobalStateSnapshot, _MultiProcessingLauncher
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 5 for calling a global function with example usage: test_global_state_snapshot() without return types