code: def test_trunc_gumbel(shape):
      #  We first just verify that the samples are smaller than the provided threshold (i.e. they are truncated)
      #  And also attempt to remove the truncation and verify if it is sampled from a gumbel distribution
      #  using a KS-test with another sampled gumbel distribution
  
      # Verifying if the distribution is truncated
      for i in range(1000):
          samples = trunc_gumbel(mx.np.ones(shape), 1.0).asnumpy()
          assert (samples < 1.0).all()
  
      # perform ks-tests
      pvalues = []
      for i in range(1000):
          logits = mx.np.random.uniform(-2, -1, shape)
          sampled_gumbels = (
              mx.np.random.gumbel(mx.np.zeros_like(logits)) + logits
          )  # sample a gumbel distribution
  
          # sample a potential truncated gumbel distribution
          gumbels = (
              mx.np.random.gumbel(mx.np.zeros_like(logits)) + logits
          )
          sampled_truncated_gumbels = trunc_gumbel(logits, 0.5)
  
          # remove the truncation
          reconstructed_sample = -mx.np.log(
              mx.np.exp(-sampled_truncated_gumbels) - mx.np.exp(-0.5)
          )
  
          pvalue = ks_2samp(
              reconstructed_sample.asnumpy(), sampled_gumbels.asnumpy()
          ).pvalue
          pvalues.append(pvalue)
  
      pvalues = np.array(pvalues)
      # Statistical inference condition: if out of all the tests, 90% of the resultant p-values > 0.05,
      # accept the null hypothesis (i.e. the reconstructed_samples indeed arrive from a gumbel distribution)
      assert len(pvalues[pvalues > 0.05]) > 900
  
file_path: gluon-nlp/tests/test_op.py
imports: import numpy
  from numpy.testing import assert_allclose
  import mxnet
  from mxnet import gluon
  from scipy.stats import ks_2samp
  import pytest
  from gluonnlp.op import *
label_desc: Use image node_id 5 for calling a global function with example usage: test_trunc_gumbel(shape) without return types