code: def _torchrun_launch(args: Namespace, script_args: List[str]) -> None:
      """This will invoke `torchrun` programmatically to launch the given script in new processes."""
      import torch.distributed.run as torchrun
  
      num_processes = (
          1
          if args.strategy == "dp"
          else _get_num_processes(args.accelerator, args.devices)
      )
  
      torchrun_args = [
          f"--nproc_per_node={num_processes}",
          f"--nnodes={args.num_nodes}",
          f"--node_rank={args.node_rank}",
          f"--master_addr={args.main_address}",
          f"--master_port={args.main_port}",
          args.script,
      ]
      torchrun_args.extend(script_args)
  
      # set a good default number of threads for OMP to avoid warnings being emitted to the user
      os.environ.setdefault(
          "OMP_NUM_THREADS", str(_suggested_max_num_threads())
      )
      torchrun.main(torchrun_args)
  
file_path: pytorch-lightning/src/lightning/fabric/cli.py
imports: import logging
  import os
  import re
  from argparse import Namespace
  from typing import Any, List, Optional
  from lightning_utilities.core.imports import RequirementCache
  from typing_extensions import get_args
  from lightning.fabric.accelerators import CPUAccelerator, CUDAAccelerator, MPSAccelerator
  from lightning.fabric.plugins.precision.precision import _PRECISION_INPUT_STR, _PRECISION_INPUT_STR_ALIAS
  from lightning.fabric.strategies import STRATEGY_REGISTRY
  from lightning.fabric.utilities.device_parser import _parse_gpu_ids
  from lightning.fabric.utilities.distributed import _suggested_max_num_threads
label_desc: Use image node_id 4 for calling a global function with example usage: _torchrun_launch(args, script_args) without return types