# -*- coding: utf-8 -*-"""The base class for benchmark evaluation."""fromabcimportABC,abstractmethodfromtypingimportGeneratorfrom._taskimportTask
[文档]classBenchmarkBase(ABC):"""The base class for benchmark evaluation."""name:str"""The name of the benchmark."""description:str"""The description of the benchmark."""
[文档]def__init__(self,name:str,description:str)->None:"""Initialize the benchmark. Args: name (`str`): The name of the benchmark. description (`str`): A brief description of the benchmark. """self.name=nameself.description=description
@abstractmethoddef__iter__(self)->Generator[Task,None,None]:"""Iterate over the benchmark."""raiseNotImplementedError("Subclasses must implement this method.")@abstractmethoddef__len__(self)->int:"""Get the length of the benchmark."""raiseNotImplementedError("Subclasses must implement this method.")@abstractmethoddef__getitem__(self,index:int)->Task:"""Get the task at the given index."""raiseNotImplementedError("Subclasses must implement this method.")