code: def get_parser(dag_parser: bool = False) -> argparse.ArgumentParser:
      """Create and returns command line argument parser."""
      parser = DefaultHelpParser(
          prog="airflow", formatter_class=AirflowHelpFormatter
      )
      subparsers = parser.add_subparsers(
          dest="subcommand", metavar="GROUP_OR_COMMAND"
      )
      subparsers.required = True
  
      command_dict = DAG_CLI_DICT if dag_parser else ALL_COMMANDS_DICT
      for _, sub in sorted(command_dict.items()):
          _add_command(subparsers, sub)
      return parser
  
imports: from __future__ import annotations
  import argparse
  import logging
  import sys
  from argparse import Action
  from collections import Counter
  from functools import lru_cache
  from typing import TYPE_CHECKING, Iterable
  import lazy_object_proxy
  from rich_argparse import RawTextRichHelpFormatter, RichHelpFormatter
  from airflow.cli.cli_config import DAG_CLI_DICT, ActionCommand, DefaultHelpParser, GroupCommand, core_commands
  from airflow.cli.utils import CliConflictError
  from airflow.exceptions import AirflowException
  from airflow.executors.executor_loader import ExecutorLoader
  from airflow.utils.helpers import partition
  from airflow.www.extensions.init_auth_manager import get_auth_manager_cls
label_desc: Use image node_id 1 for calling a global function with example usage: get_parser(dag_parser) and returns: parser