code: def add_parser(subparsers, parent_parser):
      STAGES_HELP = "Commands to list and create stages."
  
      stage_parser = subparsers.add_parser(
          "stage",
          parents=[parent_parser],
          description=append_doc_link(STAGES_HELP, "stage"),
          help=STAGES_HELP,
          formatter_class=formatter.RawDescriptionHelpFormatter,
      )
  
      stage_subparsers = stage_parser.add_subparsers(
          dest="cmd",
          help="Use `dvc stage CMD --help` to display command-specific help.",
          required=True,
      )
  
      STAGE_ADD_HELP = "Create stage"
      stage_add_parser = stage_subparsers.add_parser(
          "add",
          parents=[parent_parser],
          description=append_doc_link(STAGE_ADD_HELP, "stage/add"),
          help=STAGE_ADD_HELP,
          formatter_class=formatter.RawDescriptionHelpFormatter,
      )
      stage_add_parser.add_argument(
          "-n", "--name", help="Name of the stage to add", required=True
      )
      _add_common_args(stage_add_parser)
      stage_add_parser.set_defaults(func=CmdStageAdd)
  
      STAGE_LIST_HELP = "List stages."
      stage_list_parser = stage_subparsers.add_parser(
          "list",
          parents=[parent_parser],
          description=append_doc_link(STAGE_LIST_HELP, "stage/list"),
          help=STAGE_LIST_HELP,
          formatter_class=formatter.RawDescriptionHelpFormatter,
      )
      stage_list_parser.add_argument(
          "targets",
          nargs="*",
          default=["dvc.yaml"],
          help=(
              "Show stages from a dvc.yaml/.dvc file or a directory. "
              "'dvc.yaml' by default"
          ),
      )
      stage_list_parser.add_argument(
          "--all",
          action="store_true",
          default=False,
          help="List all of the stages in the repo.",
      )
      stage_list_parser.add_argument(
          "--fail",
          action="store_true",
          default=False,
          help="Fail immediately, do not suppress any syntax errors.",
      )
      stage_list_parser.add_argument(
          "-R",
          "--recursive",
          action="store_true",
          default=False,
          help="List all stages inside the specified directory.",
      )
      stage_list_parser.add_argument(
          "--name-only",
          "--names-only",
          action="store_true",
          default=False,
          help="List only stage names.",
      )
      stage_list_parser.set_defaults(func=CmdStageList)
  
imports: import argparse
  import logging
  from contextlib import contextmanager
  from itertools import chain, filterfalse
  from typing import TYPE_CHECKING, Dict, Iterable, List
  from dvc.cli import completion, formatter
  from dvc.cli.command import CmdBase
  from dvc.cli.utils import append_doc_link
  from dvc.log import logger
  from dvc.utils.cli_parse import parse_params
  from dvc.utils.humanize import truncate_text
label_desc: Use image node_id 7 for calling a global function with example usage: add_parser(subparsers, parent_parser) without return types