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 / sample_size / math.log(2),
        'ntokens': ntokens,
        'nsentences': nsentences,
        'sample_size': sample_size,
    }
    ncorrect = sum(log.get('ncorrect', 0) for log in logging_outputs)
    nqueries = sum(log.get('nqueries', 0) for log in logging_outputs)
    if nqueries > 0:
        agg_output['accuracy'] = ncorrect / float(nqueries)
    return agg_output