code: def api_main(program, *args):
      parser = argparse.ArgumentParser()
      choices = ["build", "python_versions", "clean", "help"]
      parser.add_argument("command", type=str, choices=choices)
      parser.add_argument(
          "-l",
          "--language",
          default="python,cpp",
          type=str,
          help="A list of languages to build native libraries. "
          'Supported languages include "python" and "java". '
          "If not specified, only the Python library will be built.",
      )
      parsed_args = parser.parse_args(args)
  
      result = None
  
      if parsed_args.command == "build":
          kwargs = dict(
              build_python=False, build_java=False, build_cpp=False
          )
          for lang in parsed_args.language.split(","):
              if "python" in lang:
                  kwargs.update(build_python=True)
              elif "java" in lang:
                  kwargs.update(build_java=True)
              elif "cpp" in lang:
                  kwargs.update(build_cpp=True)
              else:
                  raise ValueError(
                      "invalid language: {!r}".format(lang)
                  )
          result = build(**kwargs)
      elif parsed_args.command == "python_versions":
          for version in SUPPORTED_PYTHONS:
              # NOTE: On Windows this will print "\r\n" on the command line.
              # Strip it out by piping to tr -d "\r".
              print(".".join(map(str, version)))
      elif parsed_args.command == "clean":
  
          def onerror(function, path, excinfo):
              nonlocal result
              if excinfo[1].errno != errno.ENOENT:
                  msg = excinfo[1].strerror
                  logger.error("cannot remove {}: {}".format(path, msg))
                  result = 1
  
          for subdir in CLEANABLE_SUBDIRS:
              shutil.rmtree(
                  os.path.join(ROOT_DIR, subdir), onerror=onerror
              )
      elif parsed_args.command == "help":
          parser.print_help()
      else:
          raise ValueError(
              "Invalid command: {!r}".format(parsed_args.command)
          )
  
      return result
  
imports: import argparse
  import errno
  import io
  import logging
  import os
  import pathlib
  import re
  import shlex
  import shutil
  import subprocess
  import sys
  import urllib.error
  import urllib.parse
  import urllib.request
  import warnings
  from enum import Enum
  from itertools import chain
label_desc: Use image node_id 13 for calling a global function with example usage: api_main(program) and returns: result