def METHOD_NAME(
    request: pytest.FixtureRequest,
    test_data_dir: Path,
    module_path: Path,
    snap_dir: Path,
    snap_count: Counter[str],
) -> SnapshotFunc:
    """Create a snaphot for some given data."""
    fn_name = request.function.__name__
    module_name = module_path.name
    def snapshot_data(data: Any, name: str | None = None) -> None:
        if os.environ.get("SNAPSHOT_IGNORE"):
            # For the tests with old dependencies, we avoid comparing the snapshots,
            # as they might change in subtle ways between dependency versions.
            return
        snap_count[fn_name] += 1
        filename = f"{module_name}-{fn_name}"
        if name:
            filename = f"{filename}-{name}"
        elif snap_count[fn_name] > 1:
            filename = f"{filename}-{snap_count[fn_name]}"
        snap_file = snap_dir / filename
        # print strings directly, otherwise try pretty-printing
        out = data if isinstance(data, str) else pformat(data)
        # replace today
        out = out.replace(str(datetime.date.today()), "TODAY")
        # replace relative dates
        out = re.sub(r"\d+ days ago", "X days ago", out)
        # replace entry hashes
        out = re.sub(r'"[0-9a-f]{32}', '"ENTRY_HASH', out)
        out = re.sub(r"context-[0-9a-f]{32}", "context-ENTRY_HASH", out)
        # replace mtimes
        out = re.sub(r"mtime=\d+", "mtime=MTIME", out)
        out = re.sub(r'id="ledger-mtime">\d+', 'id="ledger-mtime">MTIME', out)
        # replace env-dependant info
        out = out.replace('have_excel": false', 'have_excel": true')
        for dir_path, replacement in [
            (str(test_data_dir), "TEST_DATA_DIR"),
        ]:
            if os.name == "nt":
                search = dir_path.replace("\\", "\\\\") + "\\\\"
                out = out.replace(search, replacement + "/")
            else:
                out = out.replace(dir_path, replacement)
        if os.environ.get("SNAPSHOT_UPDATE"):
            snap_file.write_text(out, "utf-8")
        else:
            contents = (
                snap_file.read_text("utf-8") if snap_file.exists() else ""
            )
            assert out == contents, (
                "Snaphot test failed. Snapshots can be updated with "
                "`SNAPSHOT_UPDATE=1 pytest`"
            )
    return snapshot_data