code: def test_restore_globals(_, mp_mock, start_method):
      """Test that we pass the global state snapshot to the worker function only if we are starting with 'spawn'."""
      mp_mock.get_all_start_methods.return_value = [start_method]
      launcher = _MultiProcessingLauncher(
          strategy=Mock(), start_method=start_method
      )
      launcher.launch(function=Mock())
      function_args = mp_mock.start_processes.call_args[1]["args"]
      if start_method == "spawn":
          assert len(function_args) == 5
          assert isinstance(function_args[4], _GlobalStateSnapshot)
      else:
          assert len(function_args) == 4
  
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 4 for calling a global function with example usage: test_restore_globals(_, mp_mock, start_method) without return types