import tensorflow as tf


def true_positive_rate_at_false_positive_rate_loss(labels,
                                                   logits,
                                                   target_rate,
                                                   weights=1.0,
                                                   dual_rate_factor=0.1,
                                                   label_priors=None,
                                                   surrogate_type='xent',
                                                   lambdas_initializer=tf.constant_initializer(1.0),
                                                   reuse=None,
                                                   variables_collections=None,
                                                   trainable=True,
                                                   scope=None):
  """Computes true positive rate at false positive rate loss.
  The loss is based on a surrogate of the form
      wt * loss(+) + lambdas * (wt * loss(-) - r * (1 - pi))
