def rerank(self, hypotheses: Dict[str, Any], reference: str) -> Dict[str, Any]:
        """
        Reranks a set of hypotheses that belong to one single reference
        translation. Uses stable sorting.

        :param hypotheses: Nbest translations.
        :param reference: A single string with the actual reference translation.
        :return: Nbest translations sorted by reranking scores.
        """
        scores = [self.scoring_function(hypothesis, reference) for hypothesis in hypotheses['translations']]
        ranking = list(np.argsort(scores, kind='mergesort')[::-1])  # descending
        reranked_hypotheses = self._sort_by_ranking(hypotheses, ranking)
        if self.return_score:
            reranked_hypotheses['scores'] = [scores[i] for i in ranking]
        return reranked_hypotheses
def rerank ( self , hypotheses : Dict [ str , Any ] , reference : str ) -> Dict [ str , Any ] : scores = [ self . scoring_function ( hypothesis , reference ) for hypothesis in hypotheses [ 'translations' ] ] ranking = list ( np . argsort ( scores , kind = 'mergesort' ) [ : : - 1 ] ) reranked_hypotheses = self . _sort_by_ranking ( hypotheses , ranking ) if self . return_score : reranked_hypotheses [ 'scores' ] = [ scores [ i ] for i in ranking ] return reranked_hypotheses
Reranks a set of hypotheses that belong to one single reference
        translation. Uses stable sorting.

        :param hypotheses: Nbest translations.
        :param reference: A single string with the actual reference translation.
        :return: Nbest translations sorted by reranking scores.