code: def main():
      global FLAGS
      FLAGS = parser.parse_args()
  
      address = get_address(FLAGS.broker)
      check(address)
  
      savedir = os.path.join(
          "/checkpoint", getpass.getuser(), FLAGS.project, FLAGS.group
      )
  
      try:
          os.makedirs(savedir)
      except FileExistsError:
          sys.stderr.write(
              "Warning: Savedir path '%s' already exists\n" % savedir
          )
  
      if not os.access(savedir, os.W_OK | os.X_OK):
          sys.stderr.write("No write access to '%s'\n" % savedir)
          sys.exit(1)
  
      cmd = FLAGS.cmd % {
          "savedir": savedir,
          "broker": address,
          "project": FLAGS.project,
          "group": FLAGS.group,
      }
  
      slurm_output = os.path.join(savedir, "slurm-%A_%a.out")
  
      args = {
          "--constraint": FLAGS.constraint,
          "--job-name": "%s/%s" % (FLAGS.project, FLAGS.group),
          "--array": "0-%i" % (FLAGS.num_peers - 1),
          "--partition": FLAGS.partition,
          "--cpus-per-task": 10,
          "--gpus-per-task": 1,
          "--mem-per-cpu": "8G",
          "--time": FLAGS.time,
          "--ntasks": 1,
          "--output": slurm_output,
          "--error": slurm_output,
          "--export": "ALL",
          "--wrap": " ".join(cmd.split() + FLAGS.args),
      }
  
      execvlist = cmdlist(args)
  
      # Can't extra-escape strings for execvp, but want that for printing.
      args["--wrap"] = repr(args["--wrap"])
      print(" ".join(cmdlist(args)))
  
      if FLAGS.dry:
          return
  
      os.execvp("sbatch", execvlist)
  
file_path: moolib/py/moolib/examples/sbatch_experiment.py
imports: import argparse
  import ctypes
  import getpass
  import os
  import socket
  import sys
  import coolname
  import moolib
label_desc: Use image node_id 6 for calling a global function with example usage: main() without return types