code: def test_scalar_switch_mixture():
      srng = pt.random.RandomStream(29833)
  
      X_rv = srng.normal(-10.0, 0.1, name="X")
      Y_rv = srng.normal(10.0, 0.1, name="Y")
  
      I_rv = srng.bernoulli(0.5, name="I")
      i_vv = I_rv.clone()
      i_vv.name = "i"
  
      # When I_rv == True, X_rv flows through otherwise Y_rv does
      Z1_rv = pt.switch(I_rv, X_rv, Y_rv)
      Z1_rv.name = "Z1"
  
      assert Z1_rv.eval({I_rv: 0}) > 5
      assert Z1_rv.eval({I_rv: 1}) < -5
  
      z_vv = Z1_rv.clone()
      z_vv.name = "z1"
  
      fgraph, _, _ = construct_ir_fgraph({Z1_rv: z_vv, I_rv: i_vv})
      assert isinstance(
          fgraph.outputs[0].owner.op, MeasurableSwitchMixture
      )
  
      # building the identical graph but with a stack to check that mixture logps are identical
      Z2_rv = pt.stack((Y_rv, X_rv))[I_rv]
  
      assert Z2_rv.eval({I_rv: 0}) > 5
      assert Z2_rv.eval({I_rv: 1}) < -5
  
      z1_logp = conditional_logp({Z1_rv: z_vv, I_rv: i_vv})
      z2_logp = conditional_logp({Z2_rv: z_vv, I_rv: i_vv})
      z1_logp_combined = pt.sum(
          [pt.sum(factor) for factor in z1_logp.values()]
      )
      z2_logp_combined = pt.sum(
          [pt.sum(factor) for factor in z2_logp.values()]
      )
      np.testing.assert_almost_equal(
          0.69049938, z1_logp_combined.eval({z_vv: -10, i_vv: 1})
      )
      np.testing.assert_almost_equal(
          0.69049938, z2_logp_combined.eval({z_vv: -10, i_vv: 1})
      )
  
imports: import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  import scipy.stats.distributions
  from pytensor import function
  from pytensor.graph.basic import Variable
  from pytensor.ifelse import ifelse
  from pytensor.tensor.random.basic import CategoricalRV
  from pytensor.tensor.shape import shape_tuple
  from pytensor.tensor.subtensor import AdvancedSubtensor, AdvancedSubtensor1, Subtensor, as_index_constant
  from pymc.logprob.abstract import MeasurableVariable
  from pymc.logprob.basic import conditional_logp, logp
  from pymc.logprob.mixture import MeasurableSwitchMixture, expand_indices
  from pymc.logprob.rewriting import construct_ir_fgraph
  from pymc.logprob.utils import dirac_delta
  from pymc.testing import assert_no_rvs
  from tests.logprob.utils import scipy_logprob
label_desc: Use image node_id 10 for calling a global function with example usage: test_scalar_switch_mixture() without return types