code: def test_subprocess_script_launcher_launch_processes(_, popen_mock):
      cluster_env = Mock()
      cluster_env.creates_processes_externally = False
      cluster_env.local_rank.return_value = 0
      cluster_env.main_address = "address"
      cluster_env.main_port = 1234
  
      function = Mock()
      launcher = _SubprocessScriptLauncher(
          cluster_env, num_processes=4, num_nodes=2
      )
      num_new_processes = launcher.num_processes - 1
  
      # launches n-1 new processes, the current one will participate too
      launcher.launch(function, "positional-arg", keyword_arg=0)
  
      calls = popen_mock.call_args_list
      assert len(calls) == num_new_processes
  
      # world size in child processes
      world_sizes = [
          int(calls[i][1]["env"]["WORLD_SIZE"])
          for i in range(num_new_processes)
      ]
      assert (
          world_sizes
          == [launcher.num_processes * launcher.num_nodes]
          * num_new_processes
      )
  
      # local rank in child processes
      local_ranks = [
          int(calls[i][1]["env"]["LOCAL_RANK"])
          for i in range(num_new_processes)
      ]
      assert local_ranks == list(range(1, num_new_processes + 1))
  
      # the current process
      assert (
          int(os.environ["WORLD_SIZE"])
          == launcher.num_processes * launcher.num_nodes
      )
      assert int(os.environ["LOCAL_RANK"]) == 0
  
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 4 for calling a global function with example usage: test_subprocess_script_launcher_launch_processes(_, popen_mock) without return types