code: def test_truncation_continuous_random(op_type, lower, upper, scalar):
      loc = 0.15
      scale = 10
      normal_op = icdf_normal if op_type == "icdf" else rejection_normal
      x = normal_op(loc, scale, name="x", size=() if scalar else (100,))
  
      xt = Truncated.dist(x, lower=lower, upper=upper)
      assert isinstance(xt.owner.op, TruncatedRV)
      assert xt.type.dtype == x.type.dtype
  
      xt_draws = draw(xt, draws=5)
      assert np.all(xt_draws >= lower)
      assert np.all(xt_draws <= upper)
      assert np.unique(xt_draws).size == xt_draws.size
  
      # Compare with reference
      ref_xt = scipy.stats.truncnorm(
          (lower - loc) / scale,
          (upper - loc) / scale,
          loc,
          scale,
      )
      assert (
          scipy.stats.cramervonmises(
              xt_draws.ravel(), ref_xt.cdf
          ).pvalue
          > 0.001
      )
  
      # Test max_n_steps
      xt = Truncated.dist(x, lower=lower, upper=upper, max_n_steps=1)
      if op_type == "icdf":
          xt_draws = draw(xt)
          assert np.all(xt_draws >= lower)
          assert np.all(xt_draws <= upper)
          assert np.unique(xt_draws).size == xt_draws.size
      else:
          with pytest.raises(
              TruncationError, match="^Truncation did not converge"
          ):
              draw(xt, draws=100 if scalar else 1)
  
imports: import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  import scipy
  from pytensor.tensor.random.basic import GeometricRV, NormalRV
  from pymc import Censored, Model, draw, find_MAP
  from pymc.distributions.continuous import Exponential, Gamma, TruncatedNormal, TruncatedNormalRV
  from pymc.distributions.shape_utils import change_dist_size
  from pymc.distributions.transforms import _default_transform
  from pymc.distributions.truncated import Truncated, TruncatedRV, _truncated
  from pymc.exceptions import TruncationError
  from pymc.logprob.abstract import _icdf
  from pymc.logprob.basic import logcdf, logp
  from pymc.logprob.transforms import IntervalTransform
  from pymc.logprob.utils import ParameterValueError
  from pymc.testing import assert_moment_is_expected
label_desc: Use image node_id 4 for calling a global function with example usage: test_truncation_continuous_random(op_type, lower, upper, scalar) without return types