def probe_pair_accuracy(targets, predictions):
  """Pairwise accuracy metric for probes.

  Calculates the percentage of (related movie, random popular movie) in which
  L(related) >= L(random)

  Args:
    targets: a list of strings, the target from the probe set
    predictions: a list of floats, the log likelihoods of the probes

  Returns:
    a dictionary: {"pair_accuracy": computed_value}
  """
  pairs = [(i, i+1) for i in range(0, len(predictions), 2)]
  correct = 0
  total = 0
  for i1, i2 in pairs:
    if predictions[i1] >= predictions[i2]:
      correct += 1
    total += 1

  if total == 0:
    return 0

  return {"pair_accuracy": float(correct) / total}