code: def extend_selected_args_with_prefix(
      parser: argparse.ArgumentParser,
      match_prefix: str,
      additional_prefix: str,
  ) -> argparse.ArgumentParser:
      """
      Helper function to select arguments with certain prefix and duplicate them with a replaced prefix.
      An example use case is distillation, where we want to add --teacher.model.* as a prefix to all --model.* arguments.
  
      In that case, we provide the following arguments:
      * match_prefix="--model."
      * additional_prefix="--teacher.model."
  
      Args:
          match_prefix: Prefix to select arguments for duplication.
              The value should start with "--", contain no underscores, and with ".".
          additional_prefix: Prefix to replace the @match_prefix in duplicated arguments.
              The value should start with "--", contain no underscores, and with ".".
      """
      # all arguments are stored as actions
      options = parser._actions
  
      regexp = r"--[^_]+\."
      assert re.match(
          regexp, match_prefix
      ), f"match prefix '{match_prefix}' should match regexp '{regexp}'"
      assert re.match(
          regexp, additional_prefix
      ), f"additional prefix '{additional_prefix}' should match regexp '{regexp}'"
  
      for option in options:
          option_strings = option.option_strings
          # option strings are stored as a list
          for option_string in option_strings:
              if option_string.startswith(match_prefix):
                  parser.add_argument(
                      option_string.replace(
                          match_prefix, additional_prefix
                      ),
                      nargs="?"
                      if isinstance(option, argparse._StoreTrueAction)
                      else option.nargs,
                      const=option.const,
                      default=option.default,
                      type=option.type,
                      choices=option.choices,
                      help=option.help,
                      metavar=option.metavar,
                  )
      return parser
  
file_path: ml-cvnets/options/utils.py
imports: import argparse
  import collections
  import os
  import re
  import yaml
  from options.errors import UnrecognizedYamlConfigEntry
  from utils import logger
  from utils.ddp_utils import is_master
  from utils.download_utils import get_local_path
label_desc: Use image node_id 3 for calling a global function with example usage: extend_selected_args_with_prefix(parser, match_prefix, additional_prefix) and returns: parser