from tensorflow.python.framework import ops

    rank = array_ops.rank(top_k_predictions)
    check_rank_op = control_flow_ops.Assert(
        math_ops.greater_equal(rank, 2),
        ['top_k_predictions must have rank 2 or higher, e.g. [batch_size, k].'])
    with ops.control_dependencies([check_rank_op]):
      return _streaming_sparse_precision_at_k(
          top_k_idx=top_k_predictions,
          labels=labels,
