code: def main(args):
      validate_arguments(args)
      num_workers = len(GPU_IDS) if GPU_IDS else args.cpu_trainers
      print(
          "Using program %s with args %s"
          % (args.file, " ".join(args.args))
      )
      print(
          "Using %d workers, %d parameter servers, %d GPUs."
          % (num_workers, args.num_pss, len(GPU_IDS))
      )
      cluster_spec = {
          "ps": [
              "localhost: %d" % (PORT_BASE + i)
              for i in range(args.num_pss)
          ],
          "worker": [
              "localhost: %d" % (PORT_BASE + args.num_pss + i)
              for i in range(num_workers)
          ],
      }
      processes = list(
          create_tf_jobs(cluster_spec, args.file, args.args)
      )
      try:
          print("Press ENTER to exit the training ...")
          sys.stdin.readline()
      except (
          KeyboardInterrupt
      ):  # https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt
          print("Keyboard interrupt received")
      finally:
          print("stopping all subprocesses ...")
          for p in processes:
              p.kill()
          for p in processes:
              p.wait()
          print("END")
  
file_path: TensorLayer/tensorlayer/cli/train.py
imports: import argparse
  import json
  import multiprocessing
  import os
  import platform
  import re
  import subprocess
  import sys
label_desc: Use image node_id 5 for calling a global function with example usage: main(args) without return types