import tensorflow as tf

  """
  with tf.name_scope("cross_entropy_sequence_loss"):
    losses = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=logits, labels=targets)
    loss_mask = tf.sequence_mask(tf.to_int32(sequence_length), tf.to_int32(tf.shape(targets)[0]))
    losses = losses * tf.transpose(tf.to_float(loss_mask), [1, 0])

  return losses


def dice_loss(predictions, targets, weights=1., name='dice_loss'):
  with tf.name_scope(name):
    # predictions = tf.to_float(predictions)
    targets = tf.to_float(targets)
    intersection = 2 * tf.reduce_sum(predictions * targets) + weights
    union = weights + tf.reduce_sum(predictions) + tf.reduce_sum(targets)
    loss = -(intersection / (union))
  return loss


def precision_recall_auc_loss(labels,
                              logits,
                              precision_range=(0.0, 1.0),
                              num_anchors=20,
                              weights=1.0,
                              dual_rate_factor=0.1,
                              label_priors=None,
                              surrogate_type='xent',
                              lambdas_initializer=tf.constant_initializer(1.0),
