def reduce_mean(tensor):
    """ "Obtain the mean of tensor on different GPUs."""
    if not (dist.get_world_size() and dist.is_initialized()):
        return tensor
    tensor = tensor.clone()
    dist.all_reduce(
        tensor.divide_(paddle.to_tensor(dist.get_world_size(), dtype="float32")),
        op=dist.ReduceOp.SUM,
    )
    return tensor
 "Obtain the mean of tensor on different GPUs.
ppdet/modeling/heads/co_deformable_detr_head.py