Coverage for transformer_lens/tools/__init__.py: 75%
10 statements
« prev ^ index » next coverage.py v7.10.1, created at 2026-09-21 19:27 +0000
« prev ^ index » next coverage.py v7.10.1, created at 2026-09-21 19:27 +0000
1"""TransformerLens tools package.
3This package contains utilities and tools for working with TransformerLens,
4including the model registry for discovering compatible HuggingFace models.
6Subpackages:
7 - analysis: High-level interpretability analyses (e.g. Direct Logit Attribution)
8 - model_registry: Tools for discovering and documenting supported models
10Subpackages load lazily (PEP 562): ``analysis`` pulls in torch-heavy core
11modules, so an eager import here would create a cycle for core modules that
12consume ``model_registry`` data at import time.
13"""
15import importlib
16from typing import Any
18_SUBMODULES = ("analysis", "model_registry", "training")
20__all__ = ["analysis", "model_registry", "training"]
23def __getattr__(name: str) -> Any:
24 if name in _SUBMODULES: 24 ↛ 25line 24 didn't jump to line 25 because the condition on line 24 was never true
25 return importlib.import_module(f".{name}", __name__)
26 raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
29def __dir__() -> list[str]:
30 return sorted(set(globals()) | set(_SUBMODULES))