import tensorflow as tf

                                       [0, 0, 1]], dtype=tf.int32)
    self.assertAllEqual(labels_0_n.numpy(), expected_labels_0_n.numpy())

  def test_randomly_select_one_point_per_segment(self):
    instance_labels = tf.constant([[1, 1, 1, 1, 1, 1, 1, 1],
                                   [1, 1, 2, 2, 2, 2, 2, 2],
                                   [1, 2, 2, 2, 2, 2, 2, 2],
                                   [0, 0, 0, 0, 2, 2, 2, 2],
                                   [0, 0, 0, 0, 2, 2, 2, 2]],
                                  dtype=tf.int32)
    instance_labels = tf.reshape(instance_labels, [-1])
    (indices,
     masks_t) = isu.randomly_select_one_point_per_segment(instance_labels)
    masks = tf.transpose(masks_t)
    masks = tf.reshape(masks, [3, 5, 8])
    expected_masks = self.get_instance_masks()
    selected_instances = tf.gather(instance_labels, indices)
    expected_selected_instances = tf.constant([0, 1, 2], dtype=tf.int32)
    self.assertAllEqual(selected_instances.numpy(),
                        expected_selected_instances.numpy())
    self.assertAllClose(masks.numpy(), expected_masks.numpy())

  def test_inputs_Distances_to_centers(self):
    inputs = tf.random.uniform(
        [100, 8], minval=-10, maxval=10.0, dtype=tf.float32)
    centers = tf.random.uniform(
