code: def trunc_gumbel(logits, truncation):
      """Sample from the TruncGumbel distribution.
  
      The cumulative density function (CDF) of the Truncated Gumbel distribution is defined as
  
      TruncGumbel(\alpha, truncation) \prop max(Gumbel(\alpha), truncation)
  
      To sample from the distribution, we can use the CDF inversion technique.
  
      References:
  
          1. [NIPS2014] A* Sampling, https://papers.nips.cc/paper/5449-a-sampling.pdf
          2. https://cmaddis.github.io/gumbel-machinery
  
      Parameters
      ----------
      logits
          The logits. Shape (...,)
      truncation
          The truncation. Shape (...,)
  
      Returns
      -------
      samples
          Samples from the TruncGumbel(logits, truncation)
          Shape (...,)
      """
      gumbels = np.random.gumbel(np.zeros_like(logits)) + logits
      return -np.log(np.exp(-gumbels) + np.exp(-truncation))
  
file_path: gluon-nlp/src/gluonnlp/op.py
imports: import mxnet
  from mxnet import np, npx
  import math
  from mxnet import use_np
label_desc: Use image node_id 5 for calling a global function with example usage: trunc_gumbel(logits, truncation) and returns: unknown