Skip to content

typedefs

typedefs

Source contracts and batch container types.

DatasetTaskConfig

Bases: Protocol

Task fields required by dataset explanation sources.

DatasetExperimentConfig

Bases: Protocol

Experiment fields required by dataset explanation sources.

DatasetRunnerConfig

Bases: Protocol

Config fields required by dataset explanation sources.

ExplanationBatch dataclass

ExplanationBatch(observation, actions, display_observation, metadata, preprocess_observation)

A model-ready observation window plus metadata for saving explanations.

Parameters:

Name Type Description Default
observation ObservationBatch

Observation dictionary passed to the policy attribution functions.

required
actions ActionBatch | None

Optional action dictionary from the source sample. Offline dataset mode provides normalized/tokenized action targets when the dataset contains them. Online inference mode sets this to None.

required
display_observation dict[str, Tensor]

Camera tensors used for visual overlays. These are kept separate because dataset batches may contain extra tokenized observation keys that are not displayable.

required
metadata dict[str, ExplanationMetadataValue]

Lightweight source metadata used for output filenames and reports.

required
preprocess_observation bool

Whether the explainer should run policy normalization/tokenization before attribution.

required

ExplanationBatchConsumer

Bases: Protocol

Consumes explanation batches produced by online inference hooks.

explain_batch

explain_batch(batch)

Generate and persist explanations for one batch.

Source code in src/versatil/explainability/sources/typedefs.py
def explain_batch(self, batch: ExplanationBatch) -> None:
    """Generate and persist explanations for one batch."""
    ...