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","."]
code: def __init__(
      self,
      metric: str,
      isometric_alpha: float = 0.5,
      return_score: bool = False,
  ) -> None:
      self.metric = metric
      self.isometric_alpha = isometric_alpha
      self.return_score = return_score
  
      if self.metric == C.RERANK_BLEU:
          # "add-k" smoothing is the best-performing method implemented in
          # sacrebleu.  See "Method 2" results from Chen and Cherry
          # (http://aclweb.org/anthology/W14-3346)
          self.scoring_function = partial(
              sacrebleu.sentence_bleu, smooth_method="add-k"
          )
      elif self.metric == C.RERANK_CHRF:
          self.scoring_function = sacrebleu.sentence_chrf  # type: ignore
      elif self.metric.startswith(C.RERANK_ISOMETRIC):
          self.scoring_function = partial(
              utils.compute_isometric_score,
              isometric_metric=self.metric,
              isometric_alpha=self.isometric_alpha,
          )
      else:
          raise utils.SockeyeError(
              "Scoring metric '%s' unknown. Choices are: %s"
              % (metric, C.RERANK_METRICS)
          )
  
      if self.metric == C.RERANK_ISOMETRIC_LC:
          self.ranking_indices = partial(
              self._get_ranking_indices,
              kind="mergesort",
              order="ascending",
          )
      else:
          self.ranking_indices = partial(
              self._get_ranking_indices,
              kind="mergesort",
              order="descending",
          )
  
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 1 to create a new Reranker object  with example: obj = Reranker(metric, isometric_alpha, return_score)