import tensorflow as tf

    (loss, num_active_triplets, negative_distances, mining_loss,
     num_active_mining_triplets, negative_mining_distances) = (
         compute_hard_negative_triplet_loss(
             anchor_positive_distances,
             anchor_match_distance_matrix,
             anchor_match_negative_indicator_matrix,
             margin=margin,
             use_semi_hard=use_semi_hard,
             anchor_positive_mining_distances=anchor_positive_mining_distances,
             anchor_match_mining_distance_matrix=(
                 anchor_match_mining_distance_matrix)))
    negative_distances = tf.boolean_mask(
        negative_distances,
        mask=negative_distances < negative_distances.dtype.max)
    negative_mining_distances = tf.boolean_mask(
        negative_mining_distances,
        mask=negative_distances < negative_distances.dtype.max)

    active_triplet_ratio = (
        tf.cast(num_active_triplets, dtype=tf.float32) / num_total_triplets)
    active_mining_triplet_ratio = (
        tf.cast(num_active_mining_triplets, dtype=tf.float32) /
