code: def test_multinomial_generator():
      def repeat_i(arr):
          """
          Return an array containing ordered values from 0 to arr.size()-1,
          where each value i is repeated arr[i] times.
  
          Example:
          >>> repeat_i([3, 1, 2, 1])
          [0, 0, 0, 1, 2, 2, 3]
          """
          ind = mx.nd.expand_dims(
              mx.nd.cumsum(
                  mx.nd.concat(
                      mx.nd.array([0]), arr[: arr.size - 1], dim=0
                  )
              ),
              axis=0,
          )
          data = mx.nd.ones((arr.size,))
          shape = (int(mx.nd.sum(arr).asscalar()),)
          return mx.nd.cumsum(mx.nd.scatter_nd(data, ind, shape)) - 1
  
      ctx = mx.context.current_context()
      probs = np.array([0.1, 0.2, 0.3, 0.05, 0.15, 0.2])
  
      buckets = list(range(6))
      for dtype in ["float16", "float32", "float64"]:
          generator_mx = lambda x: repeat_i(
              mx.nd.random.multinomial(
                  n=mx.nd.array([x]), p=mx.nd.array([probs]), ctx=ctx
              )[0]
          ).asnumpy()
          verify_generator(
              generator=generator_mx, buckets=buckets, probs=probs
          )
  
          generator_mx_same_seed = lambda x: np.concatenate(
              [generator_mx(x // 10) 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 20 for calling a global function with example usage: test_multinomial_generator() and returns: unknown