import tensorflow as tf


  if min_negative_keypoint_distance >= 0.0:
    anchor_match_negative_indicator_matrix = (
        compute_negative_indicator_matrix(
            anchor_points=anchor_keypoints,
            match_points=match_keypoints,
            distance_fn=keypoint_distance_fn,
            min_negative_distance=min_negative_keypoint_distance,
            anchor_point_masks=anchor_keypoint_masks,
            match_point_masks=match_keypoint_masks))
  else:
    num_anchors = tf.shape(anchor_keypoints)[0]
    anchor_match_negative_indicator_matrix = tf.math.logical_not(
        tf.eye(num_anchors, dtype=tf.bool))

  anchor_positive_distances = embedding_sample_distance_fn(
      anchor_embeddings, positive_embeddings)

  if anchor_mining_embeddings is None and positive_mining_embeddings is None:
    anchor_positive_mining_distances = anchor_positive_distances
  else:
    anchor_positive_mining_distances = embedding_sample_distance_fn(
