class_docstr: Reranks a list of hypotheses according to a sentence-level metric.
  
  :param metric: Sentence-level metric such as smoothed BLEU.
  :param return_score: If True, also return the sentence-level score.
  :param isometric_alpha: Factor for reranking with isometric criteria.
class_docstr_tok: ["Reranks","a","list","of","hypotheses","according","to","a","sentence-level","metric",".",":","param","metric",":","Sentence-level","metric","such","as","smoothed","BLEU",".",":","param","return_score",":","If","True",",","also","return","the","sentence-level","score",".",":","param","isometric_alpha",":","Factor","for","reranking","with","isometric","criteria","."]
docstr: 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.
docstr_tok: ["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","."]
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.
      """
      if self.metric == C.RERANK_BLEU or self.metric == C.RERANK_CHRF:
          scores = [
              self.scoring_function(hypothesis, [reference]).score
              for hypothesis in hypotheses["translations"]
          ]
          # BLEU, CHRF - the higher, the better
          ranking = self.ranking_indices(scores)
      elif self.metric.startswith(C.RERANK_ISOMETRIC):
          source = hypotheses["text"]
          # pylint: disable=redundant-keyword-arg
          scores = [
              self.scoring_function(
                  hypothesis, hypothesis_score[0], source
              )
              for hypothesis, hypothesis_score in zip(  # type: ignore
                  hypotheses["translations"], hypotheses["scores"]
              )
          ]
          # isometric-lc - the smaller, the better
          ranking = self.ranking_indices(scores)
      else:
          raise utils.SockeyeError(
              "Scoring metric '%s' unknown. Choices are: %s"
              % (self.metric, C.RERANK_METRICS)
          )
  
      reranked_hypotheses = self._sort_by_ranking(hypotheses, ranking)
      if self.return_score:
          reranked_hypotheses["scores"] = [scores[i] for i in ranking]
          reranked_hypotheses["score"] = reranked_hypotheses["scores"][
              0
          ]
  
      return reranked_hypotheses
  
file_path: sockeye/sockeye/rerank.py
imports: import argparse
  from functools import partial
  import json
  import logging
  import sys
  from typing import Any, Dict, List
  import numpy
  import sacrebleu
  from .None import arguments
  from .None import constants
  from .None import log
  from .None import utils
label_desc: Use image node_id 2 for calling the Reranker obj's underlying member method code with example usage: obj.rerank(hypotheses, reference) and returns: reranked_hypotheses