class_docstr: Beam search implementation for Transducer.
  
  Args:
      decoder: Decoder module.
      joint_network: Joint network module.
      beam_size: Size of the beam.
      lm: LM module.
      lm_weight: LM weight for soft fusion.
      search_type: Search algorithm to use during inference.
      max_sym_exp: Number of maximum symbol expansions at each time step. (TSD)
      u_max: Maximum expected target sequence length. (ALSD)
      nstep: Number of maximum expansion steps at each time step. (mAES)
      expansion_gamma: Allowed logp difference for prune-by-value method. (mAES)
      expansion_beta:
           Number of additional candidates for expanded hypotheses selection. (mAES)
      score_norm: Normalize final scores by length.
      nbest: Number of final hypothesis.
      streaming: Whether to perform chunk-by-chunk beam search.
class_docstr_tok: ["Beam","search","implementation","for","Transducer",".","Args",":","decoder",":","Decoder","module",".","joint_network",":","Joint","network","module",".","beam_size",":","Size","of","the","beam",".","lm",":","LM","module",".","lm_weight",":","LM","weight","for","soft","fusion",".","search_type",":","Search","algorithm","to","use","during","inference",".","max_sym_exp",":","Number","of","maximum","symbol","expansions","at","each","time","step",".","(","TSD",")","u_max",":","Maximum","expected","target","sequence","length",".","(","ALSD",")","nstep",":","Number","of","maximum","expansion","steps","at","each","time","step",".","(","mAES",")","expansion_gamma",":","Allowed","logp","difference","for","prune-by-value","method",".","(","mAES",")","expansion_beta",":","Number","of","additional","candidates","for","expanded","hypotheses","selection",".","(","mAES",")","score_norm",":","Normalize","final","scores","by","length",".","nbest",":","Number","of","final","hypothesis",".","streaming",":","Whether","to","perform","chunk-by-chunk","beam","search","."]
docstr: Return K hypotheses candidates for expansion from a list of hypothesis.
  
  K candidates are selected according to the extended hypotheses probabilities
  and a prune-by-value method. Where K is equal to beam_size + beta.
  
  Args:
      hyps: Hypotheses.
      topk_idx: Indices of candidates hypothesis.
      topk_logp: Log-probabilities of candidates hypothesis.
  
  Returns:
      k_expansions: Best K expansion hypotheses candidates.
docstr_tok: ["Return","K","hypotheses","candidates","for","expansion","from","a","list","of","hypothesis",".","K","candidates","are","selected","according","to","the","extended","hypotheses","probabilities","and","a","prune-by-value","method",".","Where","K","is","equal","to","beam_size","+","beta",".","Args",":","hyps",":","Hypotheses",".","topk_idx",":","Indices","of","candidates","hypothesis",".","topk_logp",":","Log-probabilities","of","candidates","hypothesis",".","Returns",":","k_expansions",":","Best","K","expansion","hypotheses","candidates","."]
code: def select_k_expansions(
      self,
      hyps: List[ExtendedHypothesis],
      topk_idx: torch.Tensor,
      topk_logp: torch.Tensor,
  ) -> List[ExtendedHypothesis]:
      """Return K hypotheses candidates for expansion from a list of hypothesis.
  
      K candidates are selected according to the extended hypotheses probabilities
      and a prune-by-value method. Where K is equal to beam_size + beta.
  
      Args:
          hyps: Hypotheses.
          topk_idx: Indices of candidates hypothesis.
          topk_logp: Log-probabilities of candidates hypothesis.
  
      Returns:
          k_expansions: Best K expansion hypotheses candidates.
  
      """
      k_expansions = []
  
      for i, hyp in enumerate(hyps):
          hyp_i = [
              (int(k), hyp.score + float(v))
              for k, v in zip(topk_idx[i], topk_logp[i])
          ]
          k_best_exp = max(hyp_i, key=lambda x: x[1])[1]
  
          k_expansions.append(
              sorted(
                  filter(
                      lambda x: (k_best_exp - self.expansion_gamma)
                      <= x[1],
                      hyp_i,
                  ),
                  key=lambda x: x[1],
                  reverse=True,
              )
          )
  
      return k_expansions
  
imports: from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.joint_network import JointNetwork
label_desc: Use image node_id 6 for calling the BeamSearchTransducer obj's underlying member method code with example usage: obj.select_k_expansions(hyps, topk_idx, topk_logp) and returns: k_expansions