code: def parse_args():
      argparser = argparse.ArgumentParser(
          "Runs clang-tidy on a project"
      )
      argparser.add_argument(
          "-cdb",
          type=str,
          default="cpp/build/compile_commands.json",
          help="Path to cmake-generated compilation database"
          " file. It is always found inside the root of the "
          "cmake build folder. So make sure that `cmake` has "
          "been run once before running this script!",
      )
      argparser.add_argument(
          "-exe",
          type=str,
          default="clang-tidy",
          help="Path to clang-tidy exe",
      )
      argparser.add_argument(
          "-ignore",
          type=str,
          default="[.]cu$",
          help="Regex used to ignore files from checking",
      )
      argparser.add_argument(
          "-select",
          type=str,
          default=None,
          help="Regex used to select files for checking",
      )
      argparser.add_argument(
          "-j",
          type=int,
          default=-1,
          help="Number of parallel jobs to launch.",
      )
      argparser.add_argument(
          "-c",
          "--config",
          type=str,
          help="Path to config file (default=pyproject.toml).",
      )
      args = argparser.parse_args()
  
      # Read from config file.
      try:
          config = _read_config_file(args.config or "./pyproject.toml")
      except FileNotFoundError:
          if args.config:
              # only raise if config argument was explicitly used
              raise RuntimeError(
                  f"File '{args.config}' does not exist."
              )
      else:
          argparser.set_defaults(**config)
          args = argparser.parse_args()
  
      if args.j <= 0:
          args.j = mp.cpu_count()
      args.ignore_compiled = (
          re.compile(args.ignore) if args.ignore else None
      )
      args.select_compiled = (
          re.compile(args.select) if args.select else None
      )
      ret = subprocess.check_output(
          "%s --version" % args.exe, shell=True
      )
      ret = ret.decode("utf-8")
      version = VERSION_REGEX.search(ret)
      if version is None:
          raise Exception("Failed to figure out clang-tidy version!")
      version = version.group(1)
      if version != EXPECTED_VERSION:
          raise Exception(
              "clang-tidy exe must be v%s found '%s'"
              % (EXPECTED_VERSION, version)
          )
      if not os.path.exists(args.cdb):
          raise Exception(
              "Compilation database '%s' missing" % args.cdb
          )
      return args
  
imports: import argparse
  import json
  import multiprocessing
  import os
  import re
  import shutil
  import subprocess
  import sys
  from pathlib import Path
  import tomli
label_desc: Use image node_id 2 for calling a global function with example usage: parse_args() and returns: args