from tensorflow.python.framework import ops

      value matches `metric`.
  """
  default_name = _at_k_name('average_precision', k)
  with ops.name_scope(name, default_name, (predictions, labels)) as scope:
    # Calculate per-example average precision, and apply weights.
    average_precision = sparse_average_precision_at_k(
