code: def main():
      spin = ["-", "/", "|", "\\", "-", "/", "|", "\\"]
      logGroupName = "/aws/batch/job"
  
      jobName = re.sub("[^A-Za-z0-9_\-]", "", args.name)[
          :128
      ]  # Enforce AWS Batch jobName rules
      jobType = args.job_type
      jobQueue = instance_type_info[jobType]["job_queue"]
      jobDefinition = instance_type_info[jobType]["job_definition"]
      command = args.command.split()
      wait = args.wait
  
      parameters = {
          "SOURCE_REF": args.source_ref,
          "WORK_DIR": args.work_dir,
          "SAVED_OUTPUT": args.saved_output,
          "SAVE_PATH": args.save_path,
          "COMMAND": args.command,
          "REMOTE": args.remote,
      }
      kwargs = dict(
          jobName=jobName,
          jobQueue=jobQueue,
          jobDefinition=jobDefinition,
          parameters=parameters,
      )
      if args.timeout is not None:
          kwargs["timeout"] = {"attemptDurationSeconds": args.timeout}
      submitJobResponse = batch.submit_job(**kwargs)
  
      jobId = submitJobResponse["jobId"]
      print(
          "Submitted job [{} - {}] to the job queue [{}]".format(
              jobName, jobId, jobQueue
          )
      )
  
      spinner = 0
      running = False
      status_set = set()
      startTime = 0
      logStreamName = None
      while wait:
          time.sleep(random.randint(5, 10))
          describeJobsResponse = batch.describe_jobs(jobs=[jobId])
          status = describeJobsResponse["jobs"][0]["status"]
          if status == "SUCCEEDED" or status == "FAILED":
              if logStreamName:
                  startTime = (
                      printLogs(logGroupName, logStreamName, startTime)
                      + 1
                  )
              print("=" * 80)
              print("Job [{} - {}] {}".format(jobName, jobId, status))
              sys.exit(status == "FAILED")
  
          elif status == "RUNNING":
              logStreamName = describeJobsResponse["jobs"][0][
                  "container"
              ]["logStreamName"]
              if not running:
                  running = True
                  print(
                      "\rJob [{}, {}] is RUNNING.".format(
                          jobName, jobId
                      )
                  )
                  if logStreamName:
                      print(
                          "Output [{}]:\n {}".format(
                              logStreamName, "=" * 80
                          )
                      )
              if logStreamName:
                  startTime = (
                      printLogs(logGroupName, logStreamName, startTime)
                      + 1
                  )
          elif status not in status_set:
              status_set.add(status)
              print(
                  "\rJob [%s - %s] is %-9s... %s"
                  % (jobName, jobId, status, spin[spinner % len(spin)]),
              )
              sys.stdout.flush()
              spinner += 1
  
file_path: gluon-nlp/tools/batch/submit-job.py
imports: import argparse
  import random
  import re
  import sys
  import time
  from datetime import datetime
  import boto3
  from botocore.compat import total_seconds
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types