code: def test_sample(alpha, beta):
      num_samples = 100
      d = dist.Stable(alpha, beta, coords="S")
  
      def sampler(size):
          # Temporarily increase radius to test hole-patching logic.
          # Scipy doesn't handle values of alpha very close to 1.
          try:
              old = pyro.distributions.stable.RADIUS
              pyro.distributions.stable.RADIUS = 0.02
              return d.sample([size])
          finally:
              pyro.distributions.stable.RADIUS = old
  
      def cdf(x):
          with warnings.catch_warnings(record=True) as w:
              warnings.simplefilter(
                  "always", category=IntegrationWarning
              )
              result = levy_stable.cdf(x, alpha, beta)
          # Scipy has only an experimental .cdf() function for alpha=1, beta!=0.
          # It sometimes passes and sometimes xfails.
          if w and alpha == 1 and beta != 0:
              pytest.xfail(
                  reason="scipy.stats.levy_stable.cdf is unstable"
              )
          return result
  
      assert kstest(sampler, cdf, N=num_samples).pvalue > 0.1
  
file_path: pyro/tests/distributions/test_stable.py
imports: import warnings
  import pytest
  import torch
  from scipy.integrate.quadpack import IntegrationWarning
  from scipy.stats import ks_2samp, kstest, levy_stable
  import pyro.distributions
  import pyro.distributions.stable
  from tests.common import assert_close
label_desc: Use image node_id 2 for calling a global function with example usage: test_sample(alpha, beta) and returns: result, d