code: def _unpack_args(
      args: t.Sequence[str], nargs_spec: t.Sequence[int]
  ) -> t.Tuple[
      t.Sequence[t.Union[str, t.Sequence[t.Optional[str]], None]],
      t.List[str],
  ]:
      """Given an iterable of arguments and an iterable of nargs specifications,
      it returns a tuple with all the unpacked arguments at the first index
      and all remaining arguments as the second.
  
      The nargs specification is the number of arguments that should be consumed
      or `-1` to indicate that this position should eat up all the remainders.
  
      Missing items are filled with `None`.
      """
      args = deque(args)
      nargs_spec = deque(nargs_spec)
      rv: t.List[t.Union[str, t.Tuple[t.Optional[str], ...], None]] = []
      spos: t.Optional[int] = None
  
      def _fetch(c: "te.Deque[V]") -> t.Optional[V]:
          try:
              if spos is None:
                  return c.popleft()
              else:
                  return c.pop()
          except IndexError:
              return None
  
      while nargs_spec:
          nargs = _fetch(nargs_spec)
  
          if nargs is None:
              continue
  
          if nargs == 1:
              rv.append(_fetch(args))
          elif nargs > 1:
              x = [_fetch(args) for _ in range(nargs)]
  
              # If we're reversed, we're pulling in the arguments in reverse,
              # so we need to turn them around.
              if spos is not None:
                  x.reverse()
  
              rv.append(tuple(x))
          elif nargs < 0:
              if spos is not None:
                  raise TypeError("Cannot have two nargs < 0")
  
              spos = len(rv)
              rv.append(None)
  
      # spos is the position of the wildcard (star).  If it's not `None`,
      # we fill it with the remainder.
      if spos is not None:
          rv[spos] = tuple(args)
          args = []
          rv[spos + 1 :] = reversed(rv[spos + 1 :])
  
      return tuple(rv), list(args)
  
imports: import typing
  from collections import deque
  from gettext import gettext
  from gettext import ngettext
  from .exceptions import BadArgumentUsage
  from .exceptions import BadOptionUsage
  from .exceptions import NoSuchOption
  from .exceptions import UsageError
label_desc: Use image node_id 1 for calling a global function with example usage: _unpack_args(args, nargs_spec) and returns: tuple,  list, c, c, None