code: def test_adaptive_embedding(
      vocab_size, cutoffs, embed_size, units, div_val
  ):
      embed = AdaptiveEmbedding(
          vocab_size=vocab_size,
          embed_size=embed_size,
          units=units,
          cutoffs=cutoffs,
          div_val=div_val,
      )
      embed.initialize()
      embed.hybridize()
      # Test for parameter number
      estimated_param_num = 0
      if isinstance(cutoffs, int):
          cutoffs = [cutoffs]
      if div_val != 1.0:
          for i, (lhs, rhs) in enumerate(
              zip([0] + cutoffs, cutoffs + [vocab_size])
          ):
              estimated_param_num += (rhs - lhs) * int(
                  embed_size / div_val**i
              )
              estimated_param_num += (
                  int(embed_size / div_val**i) * units
              )
          total_param_num = sum(
              [
                  np.prod(p.shape)
                  for p in embed.collect_params().values()
              ]
          )
      else:
          estimated_param_num = (
              vocab_size * embed_size + embed_size * units
          )
          total_param_num = sum(
              [
                  np.prod(p.shape)
                  for p in embed.collect_params().values()
              ]
          )
      assert total_param_num == estimated_param_num
      # Test for forward
      out = embed(mx.np.random.randint(0, vocab_size, 20))
      mx.npx.waitall()
      assert out.shape == (20, units)
  
file_path: gluon-nlp/tests/test_layers.py
imports: import pytest
  import numpy
  from numpy.testing import assert_allclose
  import mxnet
  from gluonnlp.layers import PositionalEmbedding, SinusoidalPositionalEmbedding, LearnedPositionalEmbedding, BucketPositionalEmbedding, AdaptiveEmbedding, ProjectedAdaptiveLogSoftmaxWithLoss, get_activation, get_norm_layer
  from gluonnlp.op import relative_position_bucket
label_desc: Use image node_id 4 for calling a global function with example usage: test_adaptive_embedding(vocab_size, cutoffs, embed_size, units, div_val) without return types