updating bgd allreduce code - 1