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","."]
code: def __init__(
      self,
      pad,
      bos,
      eos,
      unk,
      start,
      n_best,
      batch_size,
      global_scorer,
      min_length,
      block_ngram_repeat,
      exclusion_tokens,
      return_attention,
      max_length,
      sampling_temp,
      keep_topk,
      keep_topp,
      beam_size,
      ban_unk_token,
  ):
      super(GreedySearch, self).__init__(
          pad,
          bos,
          eos,
          unk,
          start,
          batch_size,
          beam_size,
          global_scorer,
          min_length,
          block_ngram_repeat,
          exclusion_tokens,
          return_attention,
          max_length,
          ban_unk_token,
      )
      self.sampling_temp = sampling_temp
      self.keep_topk = keep_topk
      self.keep_topp = keep_topp
      self.topk_scores = None
      self.beam_size = beam_size
      self.n_best = n_best
  
imports: import torch
  from torch.nn.functional import softmax
  from onmt.translate.decode_strategy import DecodeStrategy
label_desc: Use image node_id 1 to create a new GreedySearch object from inherited base classes: DecodeStrategy with example: obj = GreedySearch(pad, bos, eos, unk, start, n_best, batch_size, global_scorer, min_length, block_ngram_repeat, exclusion_tokens, return_attention, max_length, sampling_temp, keep_topk, keep_topp, beam_size, ban_unk_token)