code: def test_cli_torchrun_num_processes_launched(
      _, devices, expected, monkeypatch, fake_script
  ):
      torchrun_mock = Mock()
      monkeypatch.setattr(torch.distributed, "run", torchrun_mock)
      with pytest.raises(SystemExit) as e:
          _run_model.main(
              [
                  fake_script,
                  "--accelerator",
                  "cuda",
                  "--devices",
                  devices,
              ]
          )
      assert e.value.code == 0
      torchrun_mock.main.assert_called_with(
          [
              f"--nproc_per_node={expected}",
              "--nnodes=1",
              "--node_rank=0",
              "--master_addr=127.0.0.1",
              "--master_port=29400",
              fake_script,
          ]
      )
  
imports: import contextlib
  import os
  import subprocess
  from io import StringIO
  from unittest import mock
  from unittest.mock import Mock
  import pytest
  import torch.distributed.run
  from lightning.fabric.cli import _get_supported_strategies, _run_model
  from lightning_utilities.core.imports import ModuleAvailableCache
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 12 for calling a global function with example usage: test_cli_torchrun_num_processes_launched(_, devices, expected, monkeypatch, fake_script) without return types