code: def test_truncated_gamma():
      # Regression test for https://github.com/pymc-devs/pymc/issues/6931
      alpha = 3.0
      beta = 3.0
      upper = 2.5
      x = np.linspace(0.0, upper + 0.5, 100)
  
      gamma_scipy = scipy.stats.gamma(a=alpha, scale=1.0 / beta)
      logp_scipy = gamma_scipy.logpdf(x) - gamma_scipy.logcdf(upper)
      logp_scipy[x > upper] = -np.inf
  
      gamma_trunc_pymc = Truncated.dist(
          Gamma.dist(alpha=alpha, beta=beta),
          upper=upper,
      )
      logp_pymc = logp(gamma_trunc_pymc, x).eval()
      np.testing.assert_allclose(
          logp_pymc,
          logp_scipy,
      )
  
      # Changing the size used to invert the beta Gamma parameter again
      resized_gamma_trunc_pymc = change_dist_size(
          gamma_trunc_pymc, new_size=x.shape
      )
      logp_resized_pymc = logp(resized_gamma_trunc_pymc, x).eval()
      np.testing.assert_allclose(
          logp_resized_pymc,
          logp_scipy,
      )
  
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 17 for calling a global function with example usage: test_truncated_gamma() without return types