class_docstr: 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]
  
imports: import logging
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.joint_network import JointNetwork
  from espnet2.lm.transformer_lm import TransformerLM
  from espnet.nets.beam_search import Hypothesis
  from espnet.nets.pytorch_backend.transducer.utils import is_prefix, recombine_hyps, select_k_expansions, subtract
label_desc: Use image node_id 4 for calling the BeamSearchTransducerStreaming obj's underlying member method code with example usage: obj.sort_nbest(hyps) and returns: hyps