code: def precision_at_k(
      classes: types.TensorType,
      scores: types.TensorType,
      labels: types.TensorType,
      cutoffs: List[int],
      weights: Optional[types.TensorType] = None,
  ) -> Tuple[types.TensorType, types.TensorType]:
      # pyformat: disable
      """Precision at `k`.
  
      Args:
        classes: Tensor containing class names. Should be a BATCH_SIZE x NUM_CLASSES
          Tensor.
        scores: Tensor containing the associated scores. Should be a
          BATCH_SIZE x NUM_CLASSES Tensor.
        labels: Tensor containing the true labels. Should be a rank-2 Tensor where
          the first dimension is BATCH_SIZE. The second dimension can be anything.
        cutoffs: List containing the values for the `k` at which to compute the
          precision for. Use a value of `k` = 0 to indicate that all predictions
          should be considered.
        weights: Optional weights for each of the examples. If None,
          each of the predictions/labels will be assumed to have a weight of 1.0.
          If present, should be a BATCH_SIZE Tensor.
  
      The value_op will return a matrix with len(cutoffs) rows and 2 columns:
      [ cutoff 0, precision at cutoff 0 ]
      [ cutoff 1, precision at cutoff 1 ]
      [     :                :          ]
      [ cutoff n, precision at cutoff n ]
  
      Returns:
        (value_op, update_op) for the precision at K metric.
      """
      # pyformat: enable
      return _precision_recall_at_k(
          classes, scores, labels, cutoffs, weights, True, False
      )
  
file_path: model-analysis/tensorflow_model_analysis/post_export_metrics/metrics.py
imports: from typing import List, Optional, Tuple
  import numpy
  import tensorflow
  from tensorflow_model_analysis.api import types
label_desc: Use image node_id 6 for calling a global function with example usage: precision_at_k(classes, scores, labels, cutoffs, weights) and returns: _precision_recall_at_k