code: def _parse_args(
      parser: argparse.ArgumentParser,
  ) -> tuple[argparse.Namespace, Arguments, list[str]]:
      # argparse by default will strip out the `--` but we want to keep it for unknown arguments
      if "--" in sys.argv:
          idx = sys.argv.index("--")
          known_args = sys.argv[1:idx]
          unknown_args = sys.argv[idx:]
      else:
          known_args = sys.argv[1:]
          unknown_args = []
  
      parsed, remaining_unknown = parser.parse_known_args(known_args)
  
      # append any remaining unknown arguments from the initial parsing
      remaining_unknown.extend(unknown_args)
  
      args = model_parse(Arguments, vars(parsed))
      if not args.allow_unknown_args:
          # we have to parse twice to ensure any unknown arguments
          # result in an error if that behaviour is desired
          parser.parse_args()
  
      return parsed, args, remaining_unknown
  
imports: from __future__ import annotations
  import sys
  import logging
  import argparse
  from typing import Any, List, Type, Optional
  from typing_extensions import ClassVar
  import httpx
  import pydantic
  import openai
  from .None import _tools
  from ..None import _ApiType, __version__
  from ._api import register_commands
  from ._utils import can_use_http2
  from .._types import ProxiesDict
  from ._errors import CLIError, display_error
  from .._compat import PYDANTIC_V2, ConfigDict, model_parse
  from .._models import BaseModel
  from .._exceptions import APIError
label_desc: Use image node_id 3 for calling a global function with example usage: _parse_args(parser) and returns: parsed,  args,  remaining_unknown