def METHOD_NAME(logging_outputs):
    """Aggregate logging outputs from data parallel training."""
    loss_sum = sum(log.get("loss", 0) for log in logging_outputs)
    ntokens = sum(log.get("ntokens", 0) for log in logging_outputs)
    nsentences = sum(log.get("nsentences", 0) for log in logging_outputs)
    sample_size = sum(log.get("sample_size", 0) for log in logging_outputs)
    agg_output = {
        "loss": loss_sum / nsentences,
        "ntokens": ntokens,
        "nsentences": nsentences,
        "sample_size": sample_size,
    }
    return agg_output