def _calculate_reciprocal_rank(self, hypothesis_ids: np.ndarray, reference_id: int) -> float:
    'Calculate the reciprocal rank for a given hypothesis and reference\n            \n            Params:\n                hypothesis_ids: Iterator of hypothesis ids (as numpy array) ordered by its relevance\n                reference_id: Reference id (as a integer) of the correct id of response\n            Returns:\n                reciprocal rank\n        '
    hypothesis_ids = np.asarray(hypothesis_ids)
    try:
        rank = (np.where((hypothesis_ids == reference_id))[0][0] + 1)
    except IndexError:
        rank = (self.max_rank + 1)
    if (rank > self.max_rank):
        reciprocal_rank = 0.0
    else:
        reciprocal_rank = (1.0 / rank)
    return reciprocal_rank
Calculate the reciprocal rank for a given hypothesis and reference

Params:
    hypothesis_ids: Iterator of hypothesis ids (as numpy array) ordered by its relevance
    reference_id: Reference id (as a integer) of the correct id of response
Returns:
    reciprocal rank
def _calculate_reciprocal_rank(self, hypothesis_ids: np.ndarray, reference_id: int) -> float:
    'Calculate the reciprocal rank for a given hypothesis and reference\n            \n            Params:\n                hypothesis_ids: Iterator of hypothesis ids (as numpy array) ordered by its relevance\n                reference_id: Reference id (as a integer) of the correct id of response\n            Returns:\n                reciprocal rank\n        '
    hypothesis_ids = np.asarray(hypothesis_ids)
    try:
        rank = (np.where((hypothesis_ids == reference_id))[0][0] + 1)
    except IndexError:
        rank = (self.max_rank + 1)
    if (rank > self.max_rank):
        reciprocal_rank = 0.0
    else:
        reciprocal_rank = (1.0 / rank)
    return reciprocal_rank