class_docstr: Base class for generation strategies.
  
  Args:
    pad (int): Magic integer in output vocab.
    bos (int): Magic integer in output vocab.
    eos (int): Magic integer in output vocab.
    unk (int): Magic integer in output vocab.
    start (int): Magic integer in output vocab.
    batch_size (int): Current batch size.
    parallel_paths (int): Decoding strategies like beam search
      use parallel paths. Each batch is repeated ``parallel_paths``
      times in relevant state tensors.
    min_length (int): Shortest acceptable generation, not counting
      begin-of-sentence or end-of-sentence.
    max_length (int): Longest acceptable sequence, not counting
      begin-of-sentence (presumably there has been no EOS
      yet if max_length is used as a cutoff).
    ban_unk_token (Boolean): Whether unk token is forbidden
    block_ngram_repeat (int): Block beams where
      ``block_ngram_repeat``-grams repeat.
    exclusion_tokens (set[int]): If a gram contains any of these
      tokens, it may repeat.
    return_attention (bool): Whether to work with attention too. If this
      is true, it is assumed that the decoder is attentional.
  
  Attributes:
    pad (int): See above.
    bos (int): See above.
    eos (int): See above.
    unk (int): See above.
    start (int): See above.
    predictions (list[list[LongTensor]]): For each batch, holds a
      list of beam prediction sequences.
      scores (list[list[FloatTensor]]): For each batch, holds a
      list of scores.
    attention (list[list[FloatTensor or list[]]]): For each
      batch, holds a list of attention sequence tensors
      (or empty lists) having shape ``(step, inp_seq_len)`` where
      ``inp_seq_len`` is the length of the sample (not the max
      length of all inp seqs).
    alive_seq (LongTensor): Shape ``(B x parallel_paths, step)``.
      This sequence grows in the ``step`` axis on each call to
      :func:``advance()``.
    is_finished (ByteTensor or NoneType): Shape ``(B, parallel_paths)``.
      Initialized to ``None``.
    alive_attn (FloatTensor or NoneType): If tensor, shape is
      ``(B x parallel_paths, step, inp_seq_len)``, where ``inp_seq_len``
      is the (max) length of the input sequence.
    target_prefix (LongTensor or NoneType): If tensor, shape is
      ``(B x parallel_paths, prefix_seq_len)``, where ``prefix_seq_len``
      is the (max) length of the pre-fixed prediction.
    min_length (int): See above.
    max_length (int): See above.
    ban_unk_token (Boolean): See above.
    block_ngram_repeat (int): See above.
    exclusion_tokens (set[int]): See above.
    return_attention (bool): See above.
    done (bool): See above.
class_docstr_tok: ["Base","class","for","generation","strategies",".","Args",":","pad","(","int",")",":","Magic","integer","in","output","vocab",".","bos","(","int",")",":","Magic","integer","in","output","vocab",".","eos","(","int",")",":","Magic","integer","in","output","vocab",".","unk","(","int",")",":","Magic","integer","in","output","vocab",".","start","(","int",")",":","Magic","integer","in","output","vocab",".","batch_size","(","int",")",":","Current","batch","size",".","parallel_paths","(","int",")",":","Decoding","strategies","like","beam","search","use","parallel","paths",".","Each","batch","is","repeated","``","parallel_paths","``","times","in","relevant","state","tensors",".","min_length","(","int",")",":","Shortest","acceptable","generation",",","not","counting","begin-of-sentence","or","end-of-sentence",".","max_length","(","int",")",":","Longest","acceptable","sequence",",","not","counting","begin-of-sentence","(","presumably","there","has","been","no","EOS","yet","if","max_length","is","used","as","a","cutoff",")",".","ban_unk_token","(","Boolean",")",":","Whether","unk","token","is","forbidden","block_ngram_repeat","(","int",")",":","Block","beams","where","``","block_ngram_repeat","``","-grams","repeat",".","exclusion_tokens","(","set","[","int","]",")",":","If","a","gram","contains","any","of","these","tokens",",","it","may","repeat",".","return_attention","(","bool",")",":","Whether","to","work","with","attention","too",".","If","this","is","true",",","it","is","assumed","that","the","decoder","is","attentional",".","Attributes",":","pad","(","int",")",":","See","above",".","bos","(","int",")",":","See","above",".","eos","(","int",")",":","See","above",".","unk","(","int",")",":","See","above",".","start","(","int",")",":","See","above",".","predictions","(","list","[","list","[","LongTensor","]","]",")",":","For","each","batch",",","holds","a","list","of","beam","prediction","sequences",".","scores","(","list","[","list","[","FloatTensor","]","]",")",":","For","each","batch",",","holds","a","list","of","scores",".","attention","(","list","[","list","[","FloatTensor","or","list","[","]","]","]",")",":","For","each","batch",",","holds","a","list","of","attention","sequence","tensors","(","or","empty","lists",")","having","shape","``","(","step",",","inp_seq_len",")","``","where","``","inp_seq_len","``","is","the","length","of","the","sample","(","not","the","max","length","of","all","inp","seqs",")",".","alive_seq","(","LongTensor",")",":","Shape","``","(","B","x","parallel_paths",",","step",")","``",".","This","sequence","grows","in","the","``","step","``","axis","on","each","call","to",":","func",":","``","advance","(",")","``",".","is_finished","(","ByteTensor","or","NoneType",")",":","Shape","``","(","B",",","parallel_paths",")","``",".","Initialized","to","``","None","``",".","alive_attn","(","FloatTensor","or","NoneType",")",":","If","tensor",",","shape","is","``","(","B","x","parallel_paths",",","step",",","inp_seq_len",")","``",",","where","``","inp_seq_len","``","is","the","(","max",")","length","of","the","input","sequence",".","target_prefix","(","LongTensor","or","NoneType",")",":","If","tensor",",","shape","is","``","(","B","x","parallel_paths",",","prefix_seq_len",")","``",",","where","``","prefix_seq_len","``","is","the","(","max",")","length","of","the","pre-fixed","prediction",".","min_length","(","int",")",":","See","above",".","max_length","(","int",")",":","See","above",".","ban_unk_token","(","Boolean",")",":","See","above",".","block_ngram_repeat","(","int",")",":","See","above",".","exclusion_tokens","(","set","[","int","]",")",":","See","above",".","return_attention","(","bool",")",":","See","above",".","done","(","bool",")",":","See","above","."]
code: def ensure_unk_removed(self, log_probs):
      if self.ban_unk_token:
          log_probs[:, self.unk] = -65504
  
file_path: OpenNMT-py/onmt/translate/decode_strategy.py
imports: import torch
  from copy import deepcopy
  from onmt.utils.misc import tile
label_desc: Use image node_id 7 for calling the DecodeStrategy obj's underlying member method code with example usage: obj.ensure_unk_removed(log_probs) without return types