code: def apply_args(
      conf: BaseConfiguration, args: List[str]
  ) -> Tuple[BaseConfiguration, argparse.Namespace]:
      parser = argparse.ArgumentParser()
      configurator = run_configurators_mapping[conf.type]
      configurator.register(parser)
      conf = conf.copy(
          deep=True
      )  # to avoid modifying the original configuration
      args, unknown = parser.parse_known_args(args)
      configurator.apply(args, unknown, conf)
      return conf, args
  
file_path: dstack/src/tests/_internal/cli/services/configurators/test_run.py
imports: import argparse
  from typing import List, Tuple
  import pytest
  from dstack._internal.cli.services.configurators.run import run_configurators_mapping
  from dstack._internal.core.errors import ConfigurationError
  from dstack._internal.core.models.configurations import BaseConfiguration, PortMapping, TaskConfiguration
label_desc: Use image node_id 1 for calling a global function with example usage: apply_args(conf, args) and returns: conf,  args