code: def walk(
      rootpath: str,
      excludes: Sequence[re.Pattern[str]],
      opts: Any,
  ) -> Generator[tuple[str, list[str], list[str]], None, None]:
      """Walk through the directory and list files and subdirectories up."""
      followlinks = getattr(opts, "followlinks", False)
      includeprivate = getattr(opts, "includeprivate", False)
  
      for root, subs, files in os.walk(
          rootpath, followlinks=followlinks
      ):
          # document only Python module files (that aren't excluded)
          files = sorted(
              f
              for f in files
              if f.endswith(PY_SUFFIXES)
              and not is_excluded(path.join(root, f), excludes)
          )
  
          # remove hidden ('.') and private ('_') directories, as well as
          # excluded dirs
          if includeprivate:
              exclude_prefixes: tuple[str, ...] = (".",)
          else:
              exclude_prefixes = (".", "_")
  
          subs[:] = sorted(
              sub
              for sub in subs
              if not sub.startswith(exclude_prefixes)
              and not is_excluded(path.join(root, sub), excludes)
          )
  
          yield root, subs, files
  
imports: from __future__ import annotations
  import argparse
  import fnmatch
  import glob
  import locale
  import os
  import re
  import sys
  from copy import copy
  from importlib.machinery import EXTENSION_SUFFIXES
  from os import path
  from typing import TYPE_CHECKING, Any
  import sphinx.locale
  from sphinx import __display_version__, package_dir
  from sphinx.cmd.quickstart import EXTENSIONS
  from sphinx.locale import __
  from sphinx.util import logging
  from sphinx.util.osutil import FileAvoidWrite, ensuredir
  from sphinx.util.template import ReSTRenderer
label_desc: Use image node_id 10 for calling a global function with example usage: walk(rootpath, excludes, opts) without return types