class_docstr: Truncated distribution
  
  The pdf of a Truncated distribution is
  
  .. math::
  
      \begin{cases}
          0 & \text{for } x < lower, \\
          \frac{\text{PDF}(x, dist)}{\text{CDF}(upper, dist) - \text{CDF}(lower, dist)}
          & \text{for } lower <= x <= upper, \\
          0 & \text{for } x > upper,
      \end{cases}
  
  
  Parameters
  ----------
  dist: unnamed distribution
      Univariate distribution created via the `.dist()` API, which will be truncated.
      This distribution must be a pure RandomVariable and have a logcdf method
      implemented for MCMC sampling.
  
      .. warning:: dist will be cloned, rendering it independent of the one passed as input.
  
  lower: tensor_like of float or None
      Lower (left) truncation point. If `None` the distribution will not be left truncated.
  upper: tensor_like of float or None
      Upper (right) truncation point. If `None`, the distribution will not be right truncated.
  max_n_steps: int, defaults 10_000
      Maximum number of resamples that are attempted when performing rejection sampling.
      A `TruncationError` is raised if convergence is not reached after that many steps.
  
  Returns
  -------
  truncated_distribution: TensorVariable
      Graph representing a truncated `RandomVariable`. A specialized `Op` may be used
      if the `Op` of the dist has a dispatched `_truncated` function. Otherwise, a
      `SymbolicRandomVariable` graph representing the truncation process, via inverse
      CDF sampling (if the underlying dist has a logcdf method), or rejection sampling
      is returned.
  
  Examples
  --------
  .. code-block:: python
  
      with pm.Model():
          normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
          truncated_normal = pm.Truncated("truncated_normal", normal_dist, lower=-1, upper=1)
class_docstr_tok: ["Truncated","distribution","The","pdf","of","a","Truncated","distribution","is","..","math",":",":","\\begin","{","cases","}","0","&","\\text","{","for","}","x","<","lower",",","\\\\","\\frac","{","\\text","{","PDF","}","(","x",",","dist",")","}","{","\\text","{","CDF","}","(","upper",",","dist",")","-","\\text","{","CDF","}","(","lower",",","dist",")","}","&","\\text","{","for","}","lower","<","=","x","<","=","upper",",","\\\\","0","&","\\text","{","for","}","x",">","upper",",","\\end","{","cases","}","Parameters","--","--","--","--","--","dist",":","unnamed","distribution","Univariate","distribution","created","via","the","`",".dist","(",")","`","API",",","which","will","be","truncated",".","This","distribution","must","be","a","pure","RandomVariable","and","have","a","logcdf","method","implemented","for","MCMC","sampling",".","..","warning",":",":","dist","will","be","cloned",",","rendering","it","independent","of","the","one","passed","as","input",".","lower",":","tensor_like","of","float","or","None","Lower","(","left",")","truncation","point",".","If","`","None","`","the","distribution","will","not","be","left","truncated",".","upper",":","tensor_like","of","float","or","None","Upper","(","right",")","truncation","point",".","If","`","None","`",",","the","distribution","will","not","be","right","truncated",".","max_n_steps",":","int",",","defaults","10_000","Maximum","number","of","resamples","that","are","attempted","when","performing","rejection","sampling",".","A","`","TruncationError","`","is","raised","if","convergence","is","not","reached","after","that","many","steps",".","Returns","--","--","--","-","truncated_distribution",":","TensorVariable","Graph","representing","a","truncated","`","RandomVariable","`",".","A","specialized","`","Op","`","may","be","used","if","the","`","Op","`","of","the","dist","has","a","dispatched","`","_truncated","`","function",".","Otherwise",",","a","`","SymbolicRandomVariable","`","graph","representing","the","truncation","process",",","via","inverse","CDF","sampling","(","if","the","underlying","dist","has","a","logcdf","method",")",",","or","rejection","sampling","is","returned",".","Examples","--","--","--","--","..","code-block",":",":","python","with","pm.Model","(",")",":","normal_dist","=","pm.Normal.dist","(","mu=0.0",",","sigma=1.0",")","truncated_normal","=","pm.Truncated","(","``","truncated_normal","''",",","normal_dist",",","lower=-1",",","upper=1",")"]
code: def dist(
      cls,
      dist,
      lower=None,
      upper=None,
      max_n_steps: int = 10_000,
      **kwargs,
  ):
      if not (
          isinstance(dist, TensorVariable)
          and isinstance(dist.owner.op, RandomVariable)
      ):
          if isinstance(dist.owner.op, SymbolicRandomVariable):
              raise NotImplementedError(
                  f"Truncation not implemented for SymbolicRandomVariable {dist.owner.op}"
              )
          raise ValueError(
              f"Truncation dist must be a distribution created via the `.dist()` API, got {type(dist)}"
          )
  
      if dist.owner.op.ndim_supp > 0:
          raise NotImplementedError(
              "Truncation not implemented for multivariate distributions"
          )
  
      check_dist_not_registered(dist)
  
      if lower is None and upper is None:
          raise ValueError("lower and upper cannot both be None")
  
      return super().dist([dist, lower, upper, max_n_steps], **kwargs)
  
imports: from functools import singledispatch
  import numpy
  import pytensor
  import pytensor.tensor
  from pytensor import scan
  from pytensor.graph import Op
  from pytensor.graph.basic import Node
  from pytensor.raise_op import CheckAndRaise
  from pytensor.scan import until
  from pytensor.tensor import TensorConstant, TensorVariable
  from pytensor.tensor.random.basic import NormalRV
  from pytensor.tensor.random.op import RandomVariable
  from pymc.distributions.continuous import TruncatedNormal, bounded_cont_transform
  from pymc.distributions.dist_math import check_parameters
  from pymc.distributions.distribution import Distribution, SymbolicRandomVariable, _moment, moment
  from pymc.distributions.shape_utils import _change_dist_size, change_dist_size, to_tuple
  from pymc.distributions.transforms import _default_transform
  from pymc.exceptions import TruncationError
  from pymc.logprob.abstract import _logcdf, _logprob
  from pymc.logprob.basic import icdf, logcdf
  from pymc.math import logdiffexp
  from pymc.util import check_dist_not_registered
label_desc: Use image node_id 1 for calling the Truncated obj's underlying member method code with example usage: obj.dist(cls, dist, lower, upper, max_n_steps) and returns: super