import tensorflow as tf


    return loss, active_loss, summaries

  hard_negative_loss, hard_negative_active_loss, hard_negative_summaries = (
      compute_loss_and_create_summaries(use_semi_hard=False))
  (semi_hard_negative_loss, semi_hard_negative_active_loss,
   semi_hard_negative_summaries) = (
       compute_loss_and_create_summaries(use_semi_hard=True))

  summaries = {
      'triplet_loss/Margin':
          tf.constant(margin),
      'triplet_loss/Anchor/Positive/Distance/Mean':
          tf.math.reduce_mean(anchor_positive_distances),
      'triplet_mining/Anchor/Positive/Distance/Mean':
          tf.math.reduce_mean(anchor_positive_mining_distances),
  }
  if summarize_percentiles:
    summaries.update({
        'triplet_loss/Anchor/Positive/Distance/Median':
            tfp.stats.percentile(anchor_positive_distances, q=50),
        'triplet_mining/Anchor/Positive/Distance/Median':
