code: def _compute_sparse_average_correct(
      input_, labels, per_example_weights, topk=1):
    
    labels = tf.to_int64(labels)
    labels.get_shape().assert_is_compatible_with(
        [input_.get_shape()[0], None])
    if topk == 1:
      predictions = tf.reshape(tf.argmax(input_, 1), [-1, 1])
      in_topk = tf.reduce_any(tf.equal(labels, predictions),
                              reduction_indices=[1])
    else:
      # Use broadcasting to check if ANY of the predictions are in the top k.
      # TODO(eiderman): For a multi-label top k, what does accuracy mean?
      predictions = tf.reshape(tf.nn.top_k(input_, topk)[1], [-1, 1, topk])
      labels = tf.expand_dims(labels, [-1])
  
      in_topk = tf.reduce_any(tf.equal(tf.cast(labels, predictions.dtype),
                                       predictions),
                              reduction_indices=[1, 2])
    correct_predictions = tf.to_float(in_topk)
  
    # If individual examples are weighted, then we want to normalize by that.
    if per_example_weights is not None:
      per_example_weights = _convert_and_assert_per_example_weights_compatible(
          input_,
          per_example_weights,
          dtype=None)
      float_weights = tf.to_float(per_example_weights)
      # TODO(eiderman): This should use an op that doesn't support broadcasting.
      correct_predictions *= float_weights
      num_examples = tf.reduce_sum(float_weights)
    else:
      # shape only holds ints, but we want to always return the same type
      # for num_examples to make everything compatible.
      num_examples = tf.to_float(tf.gather(tf.shape(input_), 0))
    return tf.reduce_sum(correct_predictions), num_examples
docs: Returns the numerator and denominator of classifier accuracy.