code: def filtered_dir(
      root: str,
      include_fn: Union[
          Callable[[str, str], bool], Callable[[str], bool]
      ],
      exclude_fn: Union[
          Callable[[str, str], bool], Callable[[str], bool]
      ],
  ) -> Generator[str, None, None]:
      """Simple generator to walk a directory."""
      import inspect
  
      # compatibility with old API, which didn't pass root
      def _include_fn(path: str, root: str) -> bool:
          return (
              include_fn(path, root)  # type: ignore
              if len(inspect.signature(include_fn).parameters) == 2
              else include_fn(path)  # type: ignore
          )
  
      def _exclude_fn(path: str, root: str) -> bool:
          return (
              exclude_fn(path, root)  # type: ignore
              if len(inspect.signature(exclude_fn).parameters) == 2
              else exclude_fn(path)  # type: ignore
          )
  
      for dirpath, _, files in os.walk(root):
          for fname in files:
              file_path = os.path.join(dirpath, fname)
              if _include_fn(file_path, root) and not _exclude_fn(
                  file_path, root
              ):
                  yield file_path
  
imports: import os
  from typing import Callable, Generator, Union
label_desc: Use image node_id 2 for calling a global function with example usage: filtered_dir(root, include_fn, exclude_fn) and returns: unknown, unknown