code: def test_dirichlet():
      num_classes = 2
      num = 100
      alpha = np.random.uniform(low=0.5, high=2, size=(4, num_classes))
  
      samples = []
      results = []
      for a in alpha:
          v = ss.dirichlet.rvs(a, size=num)
          samples.append(v)
          results.append(ss.dirichlet.logpdf(v.transpose(), a))
      samples = np.concatenate(samples, axis=0).reshape(
          (2, 2, num, num_classes)
      )
      results = np.concatenate(results, axis=0).reshape((2, 2, num))
  
      alpha = alpha.reshape((2, 2, num_classes))
  
      for dtype in [np.float32, np.float64]:
          forw_atol = 1e-5
          forw_rtol = 1e-4
          for use_log in [False, True]:
              v0 = mx.sym.Variable("v0")
              v1 = mx.sym.Variable("v1")
              test_pdf = mx.sym.random_pdf_dirichlet(
                  v0, v1, is_log=use_log
              )
              res = results if use_log else np.exp(results)
              check_symbolic_forward(
                  test_pdf,
                  [samples, alpha],
                  [res],
                  atol=forw_atol,
                  rtol=forw_rtol,
                  dtype=dtype,
              )
              if dtype == np.float64:
                  backw_atol = 1e-2
                  backw_rtol = 1e-2
                  eps = 1e-5
                  check_numeric_gradient(
                      test_pdf,
                      [samples, alpha],
                      numeric_eps=eps,
                      atol=backw_atol,
                      rtol=backw_rtol,
                      dtype=dtype,
                  )
  
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 3 for calling a global function with example usage: test_dirichlet() without return types