code: def extract_files(
      # TODO: this needs to take Dict but variance issues.....
      # create protocol type ?
      query: Mapping[str, object],
      *,
      paths: Sequence[Sequence[str]],
  ) -> list[tuple[str, FileTypes]]:
      """Recursively extract files from the given dictionary based on specified paths.
  
      A path may look like this ['foo', 'files', '<array>', 'data'].
  
      Note: this mutates the given dictionary.
      """
      files: list[tuple[str, FileTypes]] = []
      for path in paths:
          files.extend(
              _extract_items(query, path, index=0, flattened_key=None)
          )
      return files
  
imports: from __future__ import annotations
  import os
  import re
  import inspect
  import functools
  from typing import Any, Tuple, Mapping, TypeVar, Callable, Iterable, Sequence, cast, overload
  from pathlib import Path
  from typing_extensions import TypeGuard
  import sniffio
  from .._types import Headers, NotGiven, FileTypes, NotGivenOr, HeadersLike
  from .._compat import parse_date, parse_datetime
label_desc: Use image node_id 2 for calling a global function with example usage: extract_files(query) and returns: files