code: def test_negative_binomial_generator():
      ctx = mx.context.current_context()
      for dtype in ["float16", "float32", "float64"]:
          success_num = 2
          success_prob = 0.2
          buckets = [(-1.0, 2.5), (2.5, 5.5), (5.5, 8.5), (8.5, np.inf)]
          probs = [
              ss.nbinom.cdf(bucket[1], success_num, success_prob)
              - ss.nbinom.cdf(bucket[0], success_num, success_prob)
              for bucket in buckets
          ]
          generator_mx = lambda x: mx.nd.random.negative_binomial(
              success_num, success_prob, shape=x, ctx=ctx, dtype=dtype
          ).asnumpy()
          verify_generator(
              generator=generator_mx, buckets=buckets, probs=probs
          )
          generator_mx_same_seed = lambda x: np.concatenate(
              [
                  mx.nd.random.negative_binomial(
                      success_num,
                      success_prob,
                      shape=x // 10,
                      ctx=ctx,
                      dtype=dtype,
                  ).asnumpy()
                  for _ in range(10)
              ]
          )
          verify_generator(
              generator=generator_mx_same_seed,
              buckets=buckets,
              probs=probs,
          )
          # Also test the Gamm-Poisson Mixture
          alpha = 1.0 / success_num
          mu = (1.0 - success_prob) / success_prob / alpha
          generator_mx = (
              lambda x: mx.nd.random.generalized_negative_binomial(
                  mu, alpha, shape=x, ctx=ctx, dtype=dtype
              ).asnumpy()
          )
          verify_generator(
              generator=generator_mx, buckets=buckets, probs=probs
          )
          generator_mx_same_seed = lambda x: np.concatenate(
              [
                  mx.nd.random.generalized_negative_binomial(
                      mu, alpha, shape=x // 10, ctx=ctx, dtype=dtype
                  ).asnumpy()
                  for _ in range(10)
              ]
          )
          verify_generator(
              generator=generator_mx_same_seed,
              buckets=buckets,
              probs=probs,
          )
  
imports: import os
  import math
  import itertools
  import mxnet
  from mxnet.test_utils import verify_generator, gen_buckets_probs_with_ppf, assert_almost_equal
  import numpy
  import random
  from common import retry, random_seed
  import scipy.stats
  import unittest
  import pytest
  from mxnet.test_utils import *
  from mxnet.base import MXNetError
  from common import assertRaises
label_desc: Use image node_id 18 for calling a global function with example usage: test_negative_binomial_generator() without return types