On the benefits of diffusion cooperation for distributed optimization and learning