code: def precision_k(
      k: int,
      y_pred: npt.NDArray[np.float32],
      y_true: npt.NDArray[np.float32],
  ) -> npt.NDArray[np.float32]:
      """
      Computes the precision@k of the predictions.
  
      Args:
          k: The number of items that are looked at for computing the precision.
          y_pred: Array of shape [N, D] with the predictions (N: number of elements, D: number of
              metrics).
          y_true: Array of shape [N, D] with the true metrics.
  
      Returns:
          Array of shape [D] with the precisions@k for each metric.
      """
      pred_ranks = (
          st.rankdata(y_pred, method="ordinal", axis=0) - 1
      )  # [N, D]
      true_ranks = (
          st.rankdata(y_true, method="ordinal", axis=0) - 1
      )  # [N, D]
  
      pred_relevance = (pred_ranks < k) / k  # [N, D]
      true_relevance = true_ranks < k  # [N, D]
  
      return (pred_relevance * true_relevance).sum(0)
  
imports: import numpy
  import numpy.typing
  import scipy.stats
label_desc: Use image node_id 4 for calling a global function with example usage: precision_k(k, y_pred, y_true) and returns: unknown