def METHOD_NAME(cls, cfg: AdaptiveLossConfig, task):
    if cfg.ddp_backend in {"c10d", "pytorch_ddp"}:
        raise Exception(
            "AdaptiveLoss is not compatible with the PyTorch "
            "version of DistributedDataParallel. Please use "
            "`--ddp-backend=legacy_ddp` instead."
        )
    return cls(task, cfg.sentence_avg)