code: def main():
      logging.basicConfig(
          format="{}: %(levelname)s %(message)s".format(script_name()),
          level=os.environ.get("LOGLEVEL", "INFO"),
      )
  
      parser = argparse.ArgumentParser(
          description="Add or check source license header"
      )
  
      parser.add_argument(
          "action",
          nargs=1,
          type=str,
          choices=["add", "check"],
          default="add",
          help="add or check",
      )
  
      parser.add_argument(
          "file",
          nargs="*",
          type=str,
          action="append",
          help="Files to add license header to",
      )
  
      args = parser.parse_args()
      action = args.action[0]
      files = list(chain.from_iterable(args.file))
      if not files and action == "check":
          if under_git():
              logging.info(
                  "Git detected: Using files under version control"
              )
              files = git_files()
          else:
              logging.info("Using files under mxnet sources root")
              files = file_generator(get_mxnet_root())
  
      if action == "check":
          logging.info("Start to check %d files", (len(files)))
          if False in [
              file_has_license(f) for f in files if os.path.exists(f)
          ]:
              return 1
          else:
              logging.info(
                  "All known and whitelisted files have license"
              )
              return 0
      else:
          assert action == "add"
          foreach(file_add_license, files)
      return 0
  
imports: import re
  import os
  import argparse
  from itertools import chain
  import logging
  import sys
  import subprocess
label_desc: Use image node_id 15 for calling a global function with example usage: main() and returns: int, int, int