code: def test_mixture_transform():
      """Make sure that non-`RandomVariable` `MeasurableVariable`s can be transformed.
  
      This test is specific to `MixtureRV`, which is derived from an `OpFromGraph`.
      """
  
      I_rv = pt.random.bernoulli(0.5, name="I")
      Y_1_rv = pt.random.beta(100, 1, name="Y_1")
      Y_2_rv = pt.random.beta(1, 100, name="Y_2")
  
      # A `MixtureRV`, which is an `OpFromGraph` subclass, will replace this
      # `pt.stack` in the graph
      Y_rv = pt.stack([Y_1_rv, Y_2_rv])[I_rv]
      Y_rv.name = "Y"
  
      i_vv = I_rv.clone()
      i_vv.name = "i"
      y_vv = Y_rv.clone()
      y_vv.name = "y"
  
      logp_no_trans = conditional_logp(
          {Y_rv: y_vv, I_rv: i_vv},
      )
      logp_no_trans_comb = pt.sum(
          [pt.sum(factor) for factor in logp_no_trans.values()]
      )
  
      transform_rewrite = TransformValuesRewrite({y_vv: LogTransform()})
  
      logp_trans = conditional_logp(
          {Y_rv: y_vv, I_rv: i_vv},
          extra_rewrites=transform_rewrite,
          use_jacobian=False,
      )
      logp_trans_combined = pt.sum(
          [pt.sum(factor) for factor in logp_trans.values()]
      )
  
      # The untransformed graph should be the same as the transformed graph after
      # replacing the `Y_rv` value variable with a transformed version of itself
      logp_nt_fg = FunctionGraph(
          outputs=[logp_no_trans_comb], clone=False
      )
      y_trans = pt.exp(y_vv)
      y_trans.name = "y_log"
      logp_nt_fg.replace(y_vv, y_trans)
      logp_nt = logp_nt_fg.outputs[0]
  
      assert equal_computations([logp_nt], [logp_trans_combined])
  
imports: import gc
  import operator
  import numpy
  import pytensor
  import pytest
  import scipy
  from numdifftools import Jacobian
  from pytensor import scan
  from pytensor import tensor
  from pytensor.compile.builders import OpFromGraph
  from pytensor.graph import FunctionGraph
  from pytensor.graph.basic import equal_computations
  import pymc
  from pymc.distributions.transforms import _default_transform, log, logodds
  from pymc.logprob import conditional_logp
  from pymc.logprob.abstract import MeasurableVariable, _logprob
  from pymc.logprob.transform_value import TransformValuesMapping, TransformValuesRewrite
  from pymc.logprob.transforms import ExpTransform, LogOddsTransform, LogTransform
  from pymc.testing import assert_no_rvs
  from tests.logprob.test_transforms import DirichletScipyDist
label_desc: Use image node_id 11 for calling a global function with example usage: test_mixture_transform() without return types