code: def spawn_launch(fn, parallel_devices):
      # TODO: the accelerator and cluster_environment should be optional to just launch processes, but this requires lazy
      # initialization to be implemented
      device_to_accelerator = {
          "cuda": CUDAAccelerator,
          "mps": MPSAccelerator,
          "cpu": CPUAccelerator,
      }
      accelerator_cls = device_to_accelerator[parallel_devices[0].type]
      strategy = DDPStrategy(
          accelerator=accelerator_cls(),
          parallel_devices=parallel_devices,
          cluster_environment=LightningEnvironment(),
          start_method="spawn",
      )
      launcher = _MultiProcessingLauncher(strategy=strategy)
      wrapped = partial(wrap_launch_function, fn, strategy)
      return launcher.launch(wrapped, strategy)
  
file_path: pytorch-lightning/tests/tests_pytorch/core/test_results.py
imports: from functools import partial
  import torch
  import torch.distributed
  from lightning.fabric.plugins.environments import LightningEnvironment
  from lightning.pytorch.accelerators import CPUAccelerator, CUDAAccelerator, MPSAccelerator
  from lightning.pytorch.strategies import DDPStrategy
  from lightning.pytorch.strategies.launchers import _MultiProcessingLauncher
  from lightning.pytorch.trainer.connectors.logger_connector.result import _Sync
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.models.test_tpu import wrap_launch_function
label_desc: Use image node_id 1 for calling a global function with example usage: spawn_launch(fn, parallel_devices) and returns: launcher