code: def check_d_samples(dfn, n, rtol=1e-2, atol=1e-2):
      counts = defaultdict(lambda: 0)
      # print 'sample', dfn.rvs(size=n)
      inc = 1 / n
      for s in dfn.rvs(size=n):
          counts[s] += inc
      for ii, p in sorted(counts.items()):
          t = np.allclose(dfn.pmf(ii), p, rtol=rtol, atol=atol)
          if not t:
              print(("Error in sampling frequencies", ii))
              print("value\tpmf\tfreq")
              for jj in sorted(counts):
                  print(
                      f"{jj:.2f}\t{dfn.pmf(jj):.3f}\t{counts[jj]:.4f}"
                  )
              npt.assert_(
                  t, "n = %i; pmf = %f; p = %f" % (n, dfn.pmf(ii), p)
              )
  
imports: from collections import defaultdict
  import unittest
  import numpy
  import numpy.testing
  from hyperopt.rdists import loguniform_gen, lognorm_gen, quniform_gen, qloguniform_gen, qnormal_gen, qlognormal_gen
  from scipy import stats
  from scipy.stats.tests.test_continuous_basic import check_cdf_logcdf, check_pdf_logpdf, check_pdf, check_cdf_ppf
label_desc: Use image node_id 1 for calling a global function with example usage: check_d_samples(dfn, n, rtol, atol) without return types