code: def test_beam_search_score(
      length, alpha, K, batch_size, vocab_size, from_logits, hybridize
  ):
      scorer = BeamSearchScorer(
          alpha=alpha, K=K, from_logits=from_logits
      )
      if hybridize:
          scorer.hybridize()
      sum_log_probs = mx.np.zeros((batch_size,))
      scores = mx.np.zeros((batch_size,))
      for step in range(1, length + 1):
          if not from_logits:
              log_probs = np.random.normal(
                  0, 1, (batch_size, vocab_size)
              )
              log_probs = np.log(
                  (scipy.special.softmax(log_probs, axis=-1))
              )
          else:
              log_probs = np.random.uniform(
                  -10, 0, (batch_size, vocab_size)
              )
          log_probs = mx.np.array(log_probs, dtype=np.float32)
          sum_log_probs += log_probs[:, 0]
          scores = scorer(log_probs, scores, mx.np.array(step))[:, 0]
      lp = (K + length) ** alpha / (K + 1) ** alpha
      assert_allclose(
          scores.asnumpy(), sum_log_probs.asnumpy() / lp, 1e-5, 1e-5
      )
  
file_path: gluon-nlp/tests/test_sequence_sampler.py
imports: import collections
  import functools
  import mxnet
  import numpy
  import scipy
  import pytest
  from mxnet.gluon import nn, HybridBlock
  from numpy.testing import assert_allclose
  from gluonnlp.sequence_sampler import BeamSearchScorer, BeamSearchSampler
label_desc: Use image node_id 1 for calling a global function with example usage: test_beam_search_score(length, alpha, K, batch_size, vocab_size, from_logits, hybridize) without return types