code: def _mean_reciprocal_rank(tp_at_topks, k_list):
      # The index of the first non-zero true positive.
      ranks = np.argmax(tp_at_topks > 0, axis=1) + 1
      # Assign infinity to the false positives as their ranks.
      ranks = np.where(tp_at_topks > 0, ranks[:, np.newaxis], np.inf)
      result = (1.0 / ranks)[:, k_list - 1]
      return result
  
imports: from collections.abc import Sequence
  import dataclasses
  from typing import Any
  import numpy
  from numpy import typing
  from tensorflow_model_analysis.experimental.lazytf import api
  from tensorflow_model_analysis.experimental.metrics.aggregates import _classification
label_desc: Use image node_id 10 for calling a global function with example usage: _mean_reciprocal_rank(tp_at_topks, k_list) and returns: result