def METHOD_NAME():
    if(module.needs_reduction):
        module.needs_reduction = False
        buckets = {}
        for param in module.parameters():
            if param.requires_grad and param.grad is not None:
                tp = type(param.data)
                if tp not in buckets:
                    buckets[tp] = []
                buckets[tp].append(param)
        if module.warn_on_half:
            if torch.cuda.HalfTensor in buckets:
                print("WARNING: gloo dist backend for half parameters may be extremely slow." +
                      " It is recommended to use the NCCL backend in this case. This currently requires" +
                      "PyTorch built from top of tree master.")
                module.warn_on_half = False
        for tp in buckets:
            bucket = buckets[tp]
            grads = [param.grad.data for param in bucket]
            coalesced = _flatten_dense_tensors(grads)
            dist.all_reduce(coalesced)
            coalesced /= dist.get_world_size()
            for buf, synced in zip(grads, _unflatten_dense_tensors(coalesced, grads)):
                buf.copy_(synced)