class_docstr: Beam search implementation for Transducer.
class_docstr_tok: ["Beam","search","implementation","for","Transducer","."]
docstr: Sort hypotheses by score or score given sequence length.
  
  Args:
      hyps: Hypothesis.
  
  Return:
      hyps: Sorted hypothesis.
docstr_tok: ["Sort","hypotheses","by","score","or","score","given","sequence","length",".","Args",":","hyps",":","Hypothesis",".","Return",":","hyps",":","Sorted","hypothesis","."]
code: def sort_nbest(
      self, hyps: Union[List[Hypothesis], List[ExtendedHypothesis]]
  ) -> Union[List[Hypothesis], List[ExtendedHypothesis]]:
      """Sort hypotheses by score or score given sequence length.
  
      Args:
          hyps: Hypothesis.
  
      Return:
          hyps: Sorted hypothesis.
  
      """
      if self.score_norm:
          hyps.sort(key=lambda x: x.score / len(x.yseq), reverse=True)
      else:
          hyps.sort(key=lambda x: x.score, reverse=True)
  
      return hyps[: self.nbest]
  
file_path: espnet/espnet/nets/beam_search_transducer.py
imports: import logging
  from typing import List, Union
  import numpy
  import torch
  from espnet.nets.pytorch_backend.transducer.custom_decoder import CustomDecoder
  from espnet.nets.pytorch_backend.transducer.joint_network import JointNetwork
  from espnet.nets.pytorch_backend.transducer.rnn_decoder import RNNDecoder
  from espnet.nets.pytorch_backend.transducer.utils import create_lm_batch_states, init_lm_state, is_prefix, recombine_hyps, select_k_expansions, select_lm_state, subtract
  from espnet.nets.transducer_decoder_interface import ExtendedHypothesis, Hypothesis
label_desc: Use image node_id 3 for calling the BeamSearchTransducer obj's underlying member method code with example usage: obj.sort_nbest(hyps) and returns: hyps