def METHOD_NAME(cls):
    if name in TASK_REGISTRY:
        raise ValueError("Cannot register duplicate task ({})".format(name))
    if not issubclass(cls, FairseqTask):
        raise ValueError(
            "Task ({}: {}) must extend FairseqTask".format(name, cls.__name__)
        )
    if cls.__name__ in TASK_CLASS_NAMES:
        raise ValueError(
            "Cannot register task with duplicate class name ({})".format(
                cls.__name__
            )
        )
    TASK_REGISTRY[name] = cls
    TASK_CLASS_NAMES.add(cls.__name__)
    if dataclass is not None and not issubclass(dataclass, FairseqDataclass):
        raise ValueError(
            "Dataclass {} must extend FairseqDataclass".format(dataclass)
        )
    cls.__dataclass = dataclass
    if dataclass is not None:
        TASK_DATACLASS_REGISTRY[name] = dataclass
        cs = ConfigStore.instance()
        node = dataclass()
        node._name = name
        cs.store(name=name, group="task", node=node, provider="fairseq")
    return cls