code: def main(override_args: List[str], script: List[str]) -> int:
      override_args = override_args or []
  
      info = det.get_cluster_info()
      assert info is not None, "must be run on-cluster"
  
      os.environ["USE_TORCH_DISTRIBUTED"] = "True"
  
      chief_ip = info.container_addrs[0]
      os.environ["DET_CHIEF_IP"] = chief_ip
  
      torch_distributed_cmd = create_launch_cmd(
          len(info.container_addrs),
          len(info.slot_ids),
          info.container_rank,
          "localhost" if len(info.container_addrs) == 1 else chief_ip,
          override_args,
      )
  
      log_redirect_cmd = create_log_redirect_cmd()
  
      # Due to a bug in PyTorch, we need to wrap the launcher in pid_server/pid_client to correctly
      # handle errors and ensure workers don't hang when a process fails
      pid_server_cmd = create_pid_server_cmd(
          info.allocation_id, len(info.slot_ids)
      )
      pid_client_cmd = create_pid_client_cmd(info.allocation_id)
  
      launch_cmd = (
          pid_server_cmd
          + torch_distributed_cmd
          + pid_client_cmd
          + log_redirect_cmd
          + script
      )
  
      logger.debug(f"Torch distributed launching with: {launch_cmd}")
  
      p = subprocess.Popen(launch_cmd)
      with det.util.forward_signals(p):
          return p.wait()
  
file_path: determined/harness/determined/launch/torch_distributed.py
imports: import argparse
  import logging
  import os
  import subprocess
  import sys
  from typing import List, Tuple
  import determined
label_desc: Use image node_id 5 for calling a global function with example usage: main(override_args, script) and returns: p