code: def _ParseArgs(
      fn_args,
      fn_defaults,
      num_required_args,
      kwargs,
      remaining_args,
      metadata,
  ):
      """Parses the positional and named arguments from the available supplied args.
  
      Modifies kwargs, removing args as they are used.
  
      Args:
        fn_args: A list of argument names that the target function accepts,
            including positional and named arguments, but not the varargs or kwargs
            names.
        fn_defaults: A list of the default values in the function argspec.
        num_required_args: The number of required arguments from the function's
            argspec. This is the number of arguments without a default value.
        kwargs: Dict with named command line arguments and their values.
        remaining_args: The remaining command line arguments, which may still be
            used as positional arguments.
        metadata: Metadata about the function, typically from Fire decorators.
      Returns:
        parsed_args: A list of values to be used as positional arguments for calling
            the target function.
        kwargs: The input dict kwargs modified with the used kwargs removed.
        remaining_args: A list of the supplied args that have not been used yet.
        capacity: Whether the call could have taken args in place of defaults.
      Raises:
        FireError: If additional positional arguments are expected, but none are
            available.
      """
      accepts_positional_args = metadata.get(
          decorators.ACCEPTS_POSITIONAL_ARGS
      )
      capacity = False  # If we see a default get used, we'll set capacity to True
  
      # Select unnamed args.
      parsed_args = []
      for index, arg in enumerate(fn_args):
          value = kwargs.pop(arg, None)
          if (
              value is not None
          ):  # A value is specified at the command line.
              value = _ParseValue(value, index, arg, metadata)
              parsed_args.append(value)
          else:  # No value has been explicitly specified.
              if remaining_args and accepts_positional_args:
                  # Use a positional arg.
                  value = remaining_args.pop(0)
                  value = _ParseValue(value, index, arg, metadata)
                  parsed_args.append(value)
              elif index < num_required_args:
                  raise FireError(
                      "The function received no value for the required argument:",
                      arg,
                  )
              else:
                  # We're past the args for which there's no default value.
                  # There's a default value for this arg.
                  capacity = True
                  default_index = (
                      index - num_required_args
                  )  # index into the defaults.
                  parsed_args.append(fn_defaults[default_index])
  
      for key, value in kwargs.items():
          kwargs[key] = _ParseValue(value, None, key, metadata)
  
      return parsed_args, kwargs, remaining_args, capacity
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import json
  import os
  import pipes
  import re
  import shlex
  import sys
  import types
  from fire import completion
  from fire import decorators
  from fire import formatting
  from fire import helptext
  from fire import inspectutils
  from fire import interact
  from fire import parser
  from fire import trace
  from fire import value_types
  from fire.console import console_io
  import six
label_desc: Use image node_id 13 for calling a global function with example usage: _ParseArgs(fn_args, fn_defaults, num_required_args, kwargs, remaining_args, metadata) and returns: parsed_args,  kwargs,  remaining_args,  capacity