def mrr(
        self,
        query: str,
        retrieved_context_chunks: List[str],
        relevance_scores: Optional[List[float]] = None,
    ) -> float:
        """
        Compute Mean Reciprocal Rank (MRR) for a given query and retrieved context chunks.

        Args:
            query (str): The input query string.
            retrieved_context_chunks (List[str]): List of retrieved context chunks.

        Returns:
            float: Computed MRR score.
        """
        ground_truth_context_chunks = (
            self._find_golden_context_chunks_and_scores(query)
        )
        if ground_truth_context_chunks:
            # Extract ground truth chunks
            golden_chunks = set(
                chunk[0] for chunk in ground_truth_context_chunks
            )

            # Sort the retrieved chunks by relevance scores if provided
            if relevance_scores:
                retrieved_with_scores = list(
                    zip(retrieved_context_chunks, relevance_scores)
                )
                # Sort in descending order of relevance score
                retrieved_with_scores.sort(key=lambda x: x[1], reverse=True)
                retrieved_context_chunks = [
                    chunk for chunk, _ in retrieved_with_scores
                ]

            # Find the rank of the first relevant item in the sorted list
            for i, chunk in enumerate(retrieved_context_chunks):
                if chunk in golden_chunks:
                    return 1 / (
                        i + 1
                    )  # MRR is the reciprocal of the rank (1-based index)

            return 0.0  # No relevant item found
        else:
            return np.nan

        Compute Mean Reciprocal Rank (MRR) for a given query and retrieved context chunks.

        Args:
            query (str): The input query string.
            retrieved_context_chunks (List[str]): List of retrieved context chunks.

        Returns:
            float: Computed MRR score.
        
src/feedback/trulens/feedback/groundtruth.py