code: def reshape_for_broadcasting(source, target):
      
      dim = len(target.get_shape())
      shape = ([1] * (dim - 1)) + [-1]
      return tf.reshape(tf.cast(source, target.dtype), shape)
docs: Reshapes a tensor (source) to have the correct shape and dtype of the target
      before broadcasting it with MPI.