code: def parse_args():
      parser = argparse.ArgumentParser(
          description="Automates building, testing, and releasing a base box"
      )
      subparsers = parser.add_subparsers(help="Action to perform.")
      subparsers.required = True
      subparsers.dest = "action"
      parser.add_argument(
          "--provider",
          choices=ALL_PROVIDERS,
          action="append",
          required=True,
          help="Name of the provider or providers to act on",
      )
  
      # "test" has special options for different platforms, and "build", "release" might
      # in the future, so we'll add the platform argument to each one individually.
      platform_help_str = "Platform to use (e.g. Arduino, Zephyr)"
  
      # Options for build subcommand
      parser_build = subparsers.add_parser(
          "build", help="Build a base box."
      )
      parser_build.set_defaults(func=build_command)
      parser_build.add_argument(
          "--debug-packer",
          action="store_true",
          help=(
              "Run packer in debug mode, and write log to the base-box directory."
          ),
      )
      parser_build.add_argument(
          "--force",
          action="store_true",
          help=(
              "Force rebuilding a base box from scratch if one already exists."
          ),
      )
  
      # Options for test subcommand
      parser_test = subparsers.add_parser(
          "test", help="Test a base box before release."
      )
      parser_test.set_defaults(func=test_command)
      parser_test.add_argument(
          "--skip-build",
          action="store_true",
          help=(
              "If given, assume a box has already been built in the release-test subdirectory, "
              "so use that box to execute the release test script. If the tests fail the VM used "
              "for testing will be left running for further investigation and will need to be "
              "destroyed manually. If all tests pass on all specified providers no VM is left running, "
              "unless --skip-destroy is given too."
          ),
      )
      parser_test.add_argument(
          "--skip-destroy",
          action="store_true",
          help=(
              "Skip destroying the test VM even if all tests pass. Can only be used if a single "
              "provider is specified. Default is to destroy the VM if all tests pass (and always "
              "skip destroying it if a test fails)."
          ),
      )
      parser_test.add_argument(
          "--test-device-serial",
          help=(
              "If given, attach the test device with this USB serial number. Corresponds to the "
              "iSerial field from `lsusb -v` output."
          ),
      )
      parser_test_platform_subparsers = parser_test.add_subparsers(
          help=platform_help_str
      )
      for platform in ALL_PLATFORMS:
          platform_specific_parser = (
              parser_test_platform_subparsers.add_parser(platform)
          )
          platform_specific_parser.set_defaults(platform=platform)
          platform_specific_parser.add_argument(
              "--microtvm-board",
              choices=ALL_MICROTVM_BOARDS[platform],
              required=True,
              help="MicroTVM board used for testing.",
          )
  
      # Options for release subcommand
      parser_release = subparsers.add_parser(
          "release", help="Release base box to cloud."
      )
      parser_release.set_defaults(func=release_command)
      parser_release.add_argument(
          "--release-version",
          required=True,
          help="Version to release, in the form 'x.y.z'. Must be specified with release.",
      )
      parser_release.add_argument(
          "--skip-creating-release-version",
          action="store_true",
          help="Skip creating the version and just upload for this provider.",
      )
      parser_release.add_argument(
          "--release-full-name",
          required=False,
          type=str,
          default=None,
          help=(
              "If set, it will use this as the full release name and version for the box. "
              "If this set, it will ignore `--release-version`."
          ),
      )
  
      args = parser.parse_args()
      return args
  
imports: import argparse
  import copy
  import json
  import logging
  import pathlib
  import os
  import re
  import shlex
  import shutil
  import subprocess
  import sys
  import pathlib
label_desc: Use image node_id 12 for calling a global function with example usage: parse_args() and returns: args