def squared_dist(A):
    expanded_a = tf.expand_dims(A, 1)
expanded_b = tf.expand_dims(A, 0)
distances = tf.reduce_sum(tf.squared_difference(expanded_a, expanded_b), 2)
return distances
Compute pairwise distance in a batch without replicating tensor in Tensorflow?