code: def register_task(name, dataclass=None):
      """
      New tasks can be added to fairseq with the
      :func:`~fairseq.tasks.register_task` function decorator.
  
      For example::
  
          @register_task('classification')
          class ClassificationTask(FairseqTask):
              (...)
  
      .. note::
  
          All Tasks must implement the :class:`~fairseq.tasks.FairseqTask`
          interface.
  
      Args:
          name (str): the name of the task
      """
  
      def register_task_cls(cls):
          if name in TASK_REGISTRY:
              return TASK_REGISTRY[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
  
      return register_task_cls
  
file_path: fairseq/fairseq/tasks/__init__.py
imports: import argparse
  import importlib
  import os
  from fairseq.dataclass import FairseqDataclass
  from fairseq.dataclass.utils import merge_with_parent
  from hydra.core.config_store import ConfigStore
  from .fairseq_task import FairseqTask, LegacyFairseqTask
label_desc: Use image node_id 2 for calling a global function with example usage: register_task(name, dataclass) and returns: register_task_cls, cls, TASK_REGISTRY