class_docstr: Beam search implementation.
docstr: Compute topk full token ids and partial token ids.
  
  Args:
      weighted_scores (torch.Tensor): The weighted sum scores for each tokens.
      Its shape is `(self.n_vocab,)`.
      ids (torch.Tensor): The partial token ids to compute topk
  
  Returns:
      Tuple[torch.Tensor, torch.Tensor]:
          The topk full token ids and partial token ids.
          Their shapes are `(self.beam_size,)`
docstr_tok: ["Compute","topk","full","token","ids","and","partial","token","ids",".","Args",":","weighted_scores","(","torch.Tensor",")",":","The","weighted","sum","scores","for","each","tokens",".","Its","shape","is","`","(","self.n_vocab",",",")","`",".","ids","(","torch.Tensor",")",":","The","partial","token","ids","to","compute","topk","Returns",":","Tuple","[","torch.Tensor",",","torch.Tensor","]",":","The","topk","full","token","ids","and","partial","token","ids",".","Their","shapes","are","`","(","self.beam_size",",",")","`"]
code: def beam(
      self, weighted_scores: torch.Tensor, ids: torch.Tensor
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Compute topk full token ids and partial token ids.
  
      Args:
          weighted_scores (torch.Tensor): The weighted sum scores for each tokens.
          Its shape is `(self.n_vocab,)`.
          ids (torch.Tensor): The partial token ids to compute topk
  
      Returns:
          Tuple[torch.Tensor, torch.Tensor]:
              The topk full token ids and partial token ids.
              Their shapes are `(self.beam_size,)`
  
      """
      # no pre beam performed
      if weighted_scores.size(0) == ids.size(0):
          top_ids = weighted_scores.topk(self.beam_size)[1]
          return top_ids, top_ids
  
      # mask pruned in pre-beam not to select in topk
      tmp = weighted_scores[ids]
      weighted_scores[:] = -float("inf")
      weighted_scores[ids] = tmp
      top_ids = weighted_scores.topk(self.beam_size)[1]
      local_ids = weighted_scores[ids].topk(self.beam_size)[1]
      return top_ids, local_ids
  
imports: import logging
  from itertools import chain
  from typing import Any, Dict, List, NamedTuple, Tuple, Union
  import torch
  from espnet.nets.e2e_asr_common import end_detect
  from espnet.nets.scorer_interface import PartialScorerInterface, ScorerInterface
label_desc: Use image node_id 7 for calling the BeamSearch obj's underlying member method code with example usage: obj.beam(weighted_scores, ids) and returns: top_ids,  local_ids, top_ids,  top_ids