class_docstr: Nucleus Sampling is a new text decoding strategy that avoids likelihood
  maximization. Rather, it works by sampling from the smallest set of top
  tokens which have a cumulative probability greater than a specified
  threshold.
  
  Present text decoding strategies like beam search do not work well on open-ended
  generation tasks (even on strong language models like GPT-2). They tend to repeat
  text a lot and the main reason behind it is that they try to maximize likelihood,
  which is a contrast from human-generated text which has a mix of high and low
  probability tokens.
  
  Nucleus Sampling is a stochastic approach and resolves this issue. Moreover,
  it improves upon other stochastic methods like top-k sampling by choosing the
  right amount of tokens to sample from. The overall result is better text
  generation on the same language model.
  
  Link to the paper introducing Nucleus Sampling (Section 6) -
  https://arxiv.org/pdf/1904.09751.pdf
  
  Args:
      vocab (list): Collection of all words in vocabulary.
      sum_threshold (float): Ceiling of sum of probabilities of tokens to
          sample from.
class_docstr_tok: ["Nucleus","Sampling","is","a","new","text","decoding","strategy","that","avoids","likelihood","maximization",".","Rather",",","it","works","by","sampling","from","the","smallest","set","of","top","tokens","which","have","a","cumulative","probability","greater","than","a","specified","threshold",".","Present","text","decoding","strategies","like","beam","search","do","not","work","well","on","open-ended","generation","tasks","(","even","on","strong","language","models","like","GPT-2",")",".","They","tend","to","repeat","text","a","lot","and","the","main","reason","behind","it","is","that","they","try","to","maximize","likelihood",",","which","is","a","contrast","from","human-generated","text","which","has","a","mix","of","high","and","low","probability","tokens",".","Nucleus","Sampling","is","a","stochastic","approach","and","resolves","this","issue",".","Moreover",",","it","improves","upon","other","stochastic","methods","like","top-k","sampling","by","choosing","the","right","amount","of","tokens","to","sample","from",".","The","overall","result","is","better","text","generation","on","the","same","language","model",".","Link","to","the","paper","introducing","Nucleus","Sampling","(","Section","6",")","-","https",":","\/\/arxiv.org\/pdf\/1904.09751.pdf","Args",":","vocab","(","list",")",":","Collection","of","all","words","in","vocabulary",".","sum_threshold","(","float",")",":","Ceiling","of","sum","of","probabilities","of","tokens","to","sample","from","."]
code: def get_result(self):
      if len(self._complete_seqs) == 0:
          captions = torch.FloatTensor([0] * 5).unsqueeze(0)
      else:
          captions = torch.FloatTensor(
              self._complete_seqs[0]
          ).unsqueeze(0)
      return captions
  
imports: import os
  import re
  from collections import Counter
  from itertools import chain
  import torch
  from mmf.common.registry import registry
  from mmf.utils.file_io import PathManager
  from mmf.utils.general import get_absolute_path
label_desc: Use image node_id 3 for calling the NucleusSampling obj's underlying member method code with example usage: obj.get_result() and returns: captions