def static_resource(namespace: str, filepath: Union[Path, str]) -> Path:
    """Get the path to a static resource file in the trulens package.

    By static here we mean something that exists in the filesystem already and
    not in some temporary folder. We use the `importlib.resources` context
    managers to get this but if the resource is temporary, the result might not
    exist by the time we return or is not expected to survive long.
    """

    if not isinstance(filepath, Path):
        filepath = Path(filepath)

    if sys.version_info >= (3, 9):
        # This does not exist in 3.8
        from importlib.abc import Traversable

        _trulens_resources: Traversable = importlib_resources.files(
            f"trulens.{namespace}"
        )
        with importlib_resources.as_file(
            _trulens_resources / filepath
        ) as _path:
            return _path
    else:
        # This is deprecated starting 3.11
        parts = filepath.parts
        with importlib_resources.path("trulens", parts[0]) as _path:
            # NOTE: resources.path does not allow the resource to include folders.
            for part in parts[1:]:
                _path = _path / part
            return _path
Get the path to a static resource file in the trulens package.

    By static here we mean something that exists in the filesystem already and
    not in some temporary folder. We use the `importlib.resources` context
    managers to get this but if the resource is temporary, the result might not
    exist by the time we return or is not expected to survive long.
    
src/core/trulens/core/utils/imports.py