code: def comparison_logprob(op, values, base_rv, operand, **kwargs):
      (value,) = values
  
      base_rv_op = base_rv.owner.op
  
      logcdf = _logcdf_helper(base_rv, operand, **kwargs)
      logccdf = pt.log1mexp(logcdf)
  
      condn_exp = pt.eq(value, np.array(True))
  
      if isinstance(op.scalar_op, (GT, GE)):
          logprob = pt.switch(condn_exp, logccdf, logcdf)
      elif isinstance(op.scalar_op, (LT, LE)):
          logprob = pt.switch(condn_exp, logcdf, logccdf)
      else:
          raise TypeError(f"Unsupported scalar_op {op.scalar_op}")
  
      if base_rv.dtype.startswith("int"):
          logpmf = _logprob_helper(base_rv, operand, **kwargs)
          logcdf_prev = _logcdf_helper(base_rv, operand - 1, **kwargs)
          if isinstance(op.scalar_op, LT):
              return pt.switch(
                  condn_exp, logcdf_prev, pt.logaddexp(logccdf, logpmf)
              )
          elif isinstance(op.scalar_op, GE):
              return pt.switch(
                  condn_exp, pt.logaddexp(logccdf, logpmf), logcdf_prev
              )
  
      if base_rv_op.name:
          logprob.name = f"{base_rv_op}_logprob"
          logcdf.name = f"{base_rv_op}_logcdf"
  
      return logprob
  
file_path: pymc/pymc/logprob/binary.py
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 GE, GT, LE, LT, Invert
  from pytensor.tensor.math import ge, gt, invert, le, lt
  from pymc.logprob.abstract import MeasurableElemwise, _logcdf_helper, _logprob, _logprob_helper
  from pymc.logprob.rewriting import PreserveRVMappings, measurable_ir_rewrites_db
  from pymc.logprob.utils import check_potential_measurability
label_desc: Use image node_id 2 for calling a global function with example usage: comparison_logprob(op, values, base_rv, operand) and returns: logprob, pt, pt