import tensorflow as tf

    # logloss not being an upper bound on the indicator function.
    weighted_loss = weights * losses_utils.weighted_surrogate_loss(
        labels, logits, surrogate_type, positive_weights=lambdas, negative_weights=1.0)
    maybe_log2 = tf.log(2.0) if surrogate_type == 'xent' else 1.0
    maybe_log2 = tf.cast(maybe_log2, logits.dtype.base_dtype)
    lambda_term = lambdas * label_priors * (target_recall - 1.0) * maybe_log2
