nodes: 0, module; 1, function_definition; 2, function_name:rerank; 3, parameters; 4, type; 5, block; 6, identifier:self; 7, typed_parameter; 8, typed_parameter; 9, generic_type; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, comment:# descending; 14, expression_statement; 15, if_statement; 16, return_statement; 17, identifier:hypotheses; 18, type; 19, identifier:reference; 20, type; 21, identifier:Dict; 22, type_parameter; 23, comment:"""
          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.
          """; 24, assignment; 25, assignment; 26, assignment; 27, attribute; 28, block; 29, identifier:reranked_hypotheses; 30, generic_type; 31, identifier:str; 32, type; 33, type; 34, identifier:scores; 35, list_comprehension; 36, identifier:ranking; 37, call; 38, identifier:reranked_hypotheses; 39, call; 40, identifier:self; 41, identifier:return_score; 42, expression_statement; 43, identifier:Dict; 44, type_parameter; 45, identifier:str; 46, identifier:Any; 47, call; 48, for_in_clause; 49, identifier:list; 50, argument_list; 51, attribute; 52, argument_list; 53, assignment; 54, type; 55, type; 56, attribute; 57, argument_list; 58, identifier:hypothesis; 59, subscript; 60, subscript; 61, identifier:self; 62, identifier:_sort_by_ranking; 63, identifier:hypotheses; 64, identifier:ranking; 65, subscript; 66, list_comprehension; 67, identifier:str; 68, identifier:Any; 69, identifier:self; 70, identifier:scoring_function; 71, identifier:hypothesis; 72, identifier:reference; 73, identifier:hypotheses; 74, string; 75, call; 76, slice; 77, identifier:reranked_hypotheses; 78, string; 79, subscript; 80, for_in_clause; 81, string_content:translations; 82, attribute; 83, argument_list; 84, unary_operator; 85, string_content:scores; 86, identifier:scores; 87, identifier:i; 88, identifier:i; 89, identifier:ranking; 90, identifier:np; 91, identifier:argsort; 92, identifier:scores; 93, keyword_argument; 94, integer:1; 95, identifier:kind; 96, string; 97, string_content:mergesort
code: 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