import tensorflow as tf

      distance_fn=embedding_sample_distance_fn)

  if anchor_mining_embeddings is None and match_mining_embeddings is None:
    anchor_match_mining_distance_matrix = anchor_match_distance_matrix
  else:
    anchor_match_mining_distance_matrix = distance_utils.compute_distance_matrix(
        anchor_embeddings if anchor_mining_embeddings is None else
        maybe_expand_sample_dim(anchor_mining_embeddings),
        match_embeddings if match_mining_embeddings is None else
        maybe_expand_sample_dim(match_mining_embeddings),
        distance_fn=embedding_sample_distance_fn)

  num_total_triplets = tf.cast(tf.shape(anchor_embeddings)[0], dtype=tf.float32)

  def compute_loss_and_create_summaries(use_semi_hard):
    """Computes loss and creates summaries."""
    (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,
