code: def test_ifelse_mixture_one_component():
      if_rv = pt.random.bernoulli(0.5, name="if")
      scale_rv = pt.random.halfnormal(name="scale")
      comp_then = pt.random.normal(
          0, scale_rv, size=(2,), name="comp_then"
      )
      comp_else = pt.random.halfnormal(
          0, scale_rv, size=(4,), name="comp_else"
      )
      mix_rv = ifelse(if_rv, comp_then, comp_else, name="mix")
  
      if_vv = if_rv.clone()
      scale_vv = scale_rv.clone()
      mix_vv = mix_rv.clone()
      mix_logp = conditional_logp(
          {if_rv: if_vv, scale_rv: scale_vv, mix_rv: mix_vv}
      )[mix_vv]
      assert_no_rvs(mix_logp)
  
      fn = function([if_vv, scale_vv, mix_vv], mix_logp)
      scale_vv_test = 0.75
      mix_vv_test = np.r_[1.0, 2.5]
      np.testing.assert_array_almost_equal(
          fn(1, scale_vv_test, mix_vv_test),
          sp.norm(0, scale_vv_test).logpdf(mix_vv_test),
      )
      mix_vv_test = np.r_[1.0, 2.5, 3.5, 4.0]
      np.testing.assert_array_almost_equal(
          fn(0, scale_vv_test, mix_vv_test),
          sp.halfnorm(0, scale_vv_test).logpdf(mix_vv_test),
      )
  
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 14 for calling a global function with example usage: test_ifelse_mixture_one_component() without return types