class_docstr: Select next tokens randomly from the top k possible next tokens.
  
  The ``scores`` attribute's lists are the score, after applying temperature,
  of the final prediction (either EOS or the final token in the event
  that ``max_length`` is reached)
  
  Args:
      pad (int): See base.
      bos (int): See base.
      eos (int): See base.
      unk (int): See base.
      start (int): See base.
      n_best (int): Don't stop until at least this many beams have
          reached EOS.
      batch_size (int): See base.
      global_scorer (onmt.translate.GNMTGlobalScorer): Scorer instance.
      min_length (int): See base.
      max_length (int): See base.
      ban_unk_token (Boolean): See base.
      block_ngram_repeat (int): See base.
      exclusion_tokens (set[int]): See base.
      return_attention (bool): See base.
      max_length (int): See base.
      sampling_temp (float): See
          :func:`~onmt.translate.greedy_search.sample_with_temperature()`.
      keep_topk (int): See
          :func:`~onmt.translate.greedy_search.sample_with_temperature()`.
      keep_topp (float): See
          :func:`~onmt.translate.greedy_search.sample_with_temperature()`.
      beam_size (int): Number of beams to use.
class_docstr_tok: ["Select","next","tokens","randomly","from","the","top","k","possible","next","tokens",".","The","``","scores","``","attribute","'s","lists","are","the","score",",","after","applying","temperature",",","of","the","final","prediction","(","either","EOS","or","the","final","token","in","the","event","that","``","max_length","``","is","reached",")","Args",":","pad","(","int",")",":","See","base",".","bos","(","int",")",":","See","base",".","eos","(","int",")",":","See","base",".","unk","(","int",")",":","See","base",".","start","(","int",")",":","See","base",".","n_best","(","int",")",":","Do","n't","stop","until","at","least","this","many","beams","have","reached","EOS",".","batch_size","(","int",")",":","See","base",".","global_scorer","(","onmt.translate.GNMTGlobalScorer",")",":","Scorer","instance",".","min_length","(","int",")",":","See","base",".","max_length","(","int",")",":","See","base",".","ban_unk_token","(","Boolean",")",":","See","base",".","block_ngram_repeat","(","int",")",":","See","base",".","exclusion_tokens","(","set","[","int","]",")",":","See","base",".","return_attention","(","bool",")",":","See","base",".","max_length","(","int",")",":","See","base",".","sampling_temp","(","float",")",":","See",":","func",":","`","~onmt.translate.greedy_search.sample_with_temperature","(",")","`",".","keep_topk","(","int",")",":","See",":","func",":","`","~onmt.translate.greedy_search.sample_with_temperature","(",")","`",".","keep_topp","(","float",")",":","See",":","func",":","`","~onmt.translate.greedy_search.sample_with_temperature","(",")","`",".","beam_size","(","int",")",":","Number","of","beams","to","use","."]
docstr: Select next tokens randomly from the top k possible next tokens.
  
  Args:
      log_probs (FloatTensor): Shaped ``(batch_size, vocab_size)``.
          These can be logits (``(-inf, inf)``) or log-probs
          (``(-inf, 0]``). (The distribution actually uses the
          log-probabilities ``logits - logits.logsumexp(-1)``,
          which equals the logits if they are log-probabilities summing
          to 1.)
      attn (FloatTensor): Shaped ``(1, B, inp_seq_len)``.
docstr_tok: ["Select","next","tokens","randomly","from","the","top","k","possible","next","tokens",".","Args",":","log_probs","(","FloatTensor",")",":","Shaped","``","(","batch_size",",","vocab_size",")","``",".","These","can","be","logits","(","``","(","-inf",",","inf",")","``",")","or","log-probs","(","``","(","-inf",",","0","]","``",")",".","(","The","distribution","actually","uses","the","log-probabilities","``","logits","-","logits.logsumexp","(","-1",")","``",",","which","equals","the","logits","if","they","are","log-probabilities","summing","to","1",".",")","attn","(","FloatTensor",")",":","Shaped","``","(","1",",","B",",","inp_seq_len",")","``","."]
code: def advance(self, log_probs, attn):
      """Select next tokens randomly from the top k possible next tokens.
  
      Args:
          log_probs (FloatTensor): Shaped ``(batch_size, vocab_size)``.
              These can be logits (``(-inf, inf)``) or log-probs
              (``(-inf, 0]``). (The distribution actually uses the
              log-probabilities ``logits - logits.logsumexp(-1)``,
              which equals the logits if they are log-probabilities summing
              to 1.)
          attn (FloatTensor): Shaped ``(1, B, inp_seq_len)``.
      """
      self.align_select_indices()
  
      self.ensure_min_length(log_probs)
      self.ensure_unk_removed(log_probs)
      self.block_ngram_repeats(log_probs)
  
      topk_ids, self.topk_scores = self._pick(log_probs)
      self.beams_scores += self.topk_scores
  
      self.is_finished_list = topk_ids.eq(self.eos).tolist()
  
      self.alive_seq = torch.cat([self.alive_seq, topk_ids], -1)
      if self.return_attention:
          if self.alive_attn is None:
              self.alive_attn = attn
          else:
              self.alive_attn = torch.cat([self.alive_attn, attn], 1)
      self.ensure_max_length()
  
imports: import torch
  from torch.nn.functional import softmax
  from onmt.translate.decode_strategy import DecodeStrategy
label_desc: Use image node_id 7 for calling the GreedySearch obj's underlying member method code with example usage: obj.advance(log_probs, attn) without return types