proto
TaskWrapperProtocol
extends
PretrainedModelProtocolProtocolTaskWrapperProtocol(config: Any)Refinement of PretrainedModelProtocol for *For<Task>
head classes (e.g. ResNetForImageClassification,
BERTForMaskedLM).
Implementations are expected to return a task-specific *Output
dataclass from forward — ImageClassificationOutput
for classifiers, MaskedLMOutput for MLM heads, etc. The
output type is not encoded in the protocol because Python's
structural typing cannot constrain method return shapes
without a Generic parameter, which would complicate the
runtime-checkable surface.
Notes
Naming rule: the class name ends with For<CapWord> matching
a key in _TASK_SUFFIX_MAP (see build script). The validator
flags For<Unknown> suffixes with MZ050 so new task types
must be explicitly registered.
Examples
>>> from lucid.models.vision.resnet import ResNetForImageClassification
>>> from lucid.models._protocols import TaskWrapperProtocol
>>> isinstance(ResNetForImageClassification, TaskWrapperProtocol)
True