code: def test_subprocess_script_launcher_can_launch(*_):
      cluster_env = Mock()
      cluster_env.creates_processes_externally = False
      cluster_env.local_rank.return_value = 1
      launcher = _SubprocessScriptLauncher(
          cluster_env, num_processes=2, num_nodes=1
      )
  
      with pytest.raises(
          RuntimeError,
          match="attempted to launch new distributed processes with `local_rank > 0`",
      ):
          launcher.launch(Mock())
  
      launcher.procs = [Mock()]  # there are already processes running
      with pytest.raises(
          RuntimeError,
          match="The launcher can only create subprocesses once",
      ):
          launcher.launch(Mock())
  
file_path: pytorch-lightning/tests/tests_fabric/strategies/launchers/test_subprocess_script.py
imports: import os
  import signal
  import sys
  from unittest import mock
  from unittest.mock import ANY, Mock
  import lightning.fabric
  import pytest
  from lightning.fabric.strategies.launchers.subprocess_script import _HYDRA_AVAILABLE, _ChildProcessObserver, _SubprocessScriptLauncher
label_desc: Use image node_id 2 for calling a global function with example usage: test_subprocess_script_launcher_can_launch() without return types