code: 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])  # 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
docs: 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.