code: def _yield_src_dest_filepaths(
      src, dest, src_base=None, target_dir=None
  ):
      """Yield src/dest path pairs
  
      Parameters
      ----------
  
      src : Path
        Source file or directory. If a directory, yields files from this
        directory recursively.
      dest : Path or None
        Destination path. Either a complete file path, or a base directory
        (see `src_base`).
      src_base : Path
        If given, the destination path will be `dest`/`src.relative_to(src_base)`
  
      Yields
      ------
      src, dest
        Path instances
      """
      if src.is_dir():
          # we only get here, when recursion is desired
          if src.name == ".git":
              # we never want to copy the git repo internals into another repo
              # this would break the target git in unforseeable ways
              return
          # special case: not yet a file to copy
          if src_base is None:
              # TODO maybe an unconditional .parent isn't a good idea,
              # if someone wants to copy a whole drive...
              src_base = src.parent
          for p in src.iterdir():
              yield from _yield_src_dest_filepaths(
                  p, dest, src_base, target_dir
              )
          return
  
      if target_dir is None and not dest:
          raise ValueError("Neither target_dir nor dest specified")
  
      if not dest:
          # no explicit destination given, build one from src and target_dir
          # reflect src hierarchy if dest is a directory, otherwise
          if src.is_absolute() and src_base:
              dest = target_dir / src.relative_to(src_base)
          else:
              dest = target_dir / src.name
  
      yield src, dest
  
imports: import logging
  import os.path
  from shutil import copyfile
  import sys
  from datalad.interface.base import Interface
  from datalad.interface.base import build_doc, eval_results
  from datalad.support.constraints import EnsureStr, EnsureNone
  from datalad.interface.common_opts import save_message_opt
  from datalad.support.param import Parameter
  from datalad.distribution.dataset import Dataset, require_dataset
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.exceptions import CapturedException
  from datalad.utils import ensure_list, get_dataset_root, Path
  from datalad.distribution.dataset import EnsureDataset, datasetmethod, resolve_path
  from functools import lru_cache
label_desc: Use image node_id 2 for calling a global function with example usage: _yield_src_dest_filepaths(src, dest, src_base, target_dir) without return types