code: def clip_logprob(
      op, values, base_rv, lower_bound, upper_bound, **kwargs
  ):
      r"""Logprob of a clipped censored distribution
  
      The probability is given by
      .. math::
          \begin{cases}
              0 & \text{for } x < lower, \\
              \text{CDF}(lower, dist) & \text{for } x = lower, \\
              \text{P}(x, dist) & \text{for } lower < x < upper, \\
              1-\text{CDF}(upper, dist) & \text {for} x = upper, \\
              0 & \text{for } x > upper,
          \end{cases}
  
      """
      (value,) = values
  
      base_rv_op = base_rv.owner.op
      base_rv_inputs = base_rv.owner.inputs
  
      logprob = _logprob(
          base_rv_op, (value,), *base_rv_inputs, **kwargs
      )
      logcdf = _logcdf(base_rv_op, value, *base_rv_inputs, **kwargs)
  
      if base_rv_op.name:
          logprob.name = f"{base_rv_op}_logprob"
          logcdf.name = f"{base_rv_op}_logcdf"
  
      is_lower_bounded, is_upper_bounded = False, False
      if not (
          isinstance(upper_bound, TensorConstant)
          and np.all(np.isinf(upper_bound.value))
      ):
          is_upper_bounded = True
  
          logccdf = pt.log1mexp(logcdf)
          # For right clipped discrete RVs, we need to add an extra term
          # corresponding to the pmf at the upper bound
          if base_rv.dtype.startswith("int"):
              logccdf = pt.logaddexp(logccdf, logprob)
  
          logprob = pt.switch(
              pt.eq(value, upper_bound),
              logccdf,
              pt.switch(pt.gt(value, upper_bound), -np.inf, logprob),
          )
      if not (
          isinstance(lower_bound, TensorConstant)
          and np.all(np.isneginf(lower_bound.value))
      ):
          is_lower_bounded = True
          logprob = pt.switch(
              pt.eq(value, lower_bound),
              logcdf,
              pt.switch(pt.lt(value, lower_bound), -np.inf, logprob),
          )
  
      if is_lower_bounded and is_upper_bounded:
          logprob = CheckParameterValue("lower_bound <= upper_bound")(
              logprob, pt.all(pt.le(lower_bound, upper_bound))
          )
  
      return logprob
  
imports: from typing import List, Optional
  import numpy
  import pytensor.tensor
  from pytensor.graph.basic import Node
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.rewriting.basic import node_rewriter
  from pytensor.scalar.basic import Ceil, Clip, Floor, RoundHalfToEven
  from pytensor.scalar.basic import clip
  from pytensor.tensor.math import ceil, clip, floor, round_half_to_even
  from pytensor.tensor.variable import TensorConstant
  from pymc.logprob.abstract import MeasurableElemwise, _logcdf, _logprob
  from pymc.logprob.rewriting import PreserveRVMappings, measurable_ir_rewrites_db
  from pymc.logprob.utils import CheckParameterValue
label_desc: Use image node_id 2 for calling a global function with example usage: clip_logprob(op, values, base_rv, lower_bound, upper_bound) and returns: logprob