import torch from torch import nn from typing import Any, Iterable, List class Model(nn.Module): """ Template model for the leaderboard. Requirements: - Must be instantiable with no arguments (called by the evaluator). - Must implement `predict(batch)` which receives an iterable of inputs and returns a list of predictions (labels). - Must implement `eval()` to place the model in evaluation mode. - If you use PyTorch, submit a state_dict to be loaded via `load_state_dict` """ def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) # Initialize your model here def eval(self) -> nn.Module: # Optional: set your model to evaluation mode return self def predict(self, batch: Iterable[Any]) -> List[Any]: """ Implement your inference here. Inputs: batch: Iterable of preprocessed inputs (as produced by your preprocess.py) Returns: A list of predictions with the same length as `batch`. """ raise NotImplementedError("Implement predict(...) to return a list of labels.") def get_model() -> Model: """ Factory function required by the evaluator. Returns an uninitialized model instance. The evaluator may optionally load weights (if provided) before calling predict(...). """ return Model()