code: def test_initial_values():
      srng = pt.random.RandomStream(seed=2320)
  
      p_S_0 = np.array([0.9, 0.1])
      S_0_rv = srng.categorical(p_S_0, name="S_0")
      S_0_rv.tag.test_value = 0
  
      Gamma_at = pt.matrix("Gamma")
      Gamma_at.tag.test_value = np.array([[0, 1], [1, 0]])
  
      s_0_vv = S_0_rv.clone()
      s_0_vv.name = "s_0"
  
      def step_fn(S_tm1, Gamma):
          S_t = srng.categorical(Gamma[S_tm1], name="S_t")
          return S_t
  
      S_1T_rv, _ = pytensor.scan(
          fn=step_fn,
          outputs_info=[{"initial": S_0_rv, "taps": [-1]}],
          non_sequences=[Gamma_at],
          strict=True,
          n_steps=10,
          name="S_0T",
      )
  
      S_1T_rv.name = "S_1T"
      s_1T_vv = S_1T_rv.clone()
      s_1T_vv.name = "s_1T"
  
      logp_parts = conditional_logp({S_1T_rv: s_1T_vv, S_0_rv: s_0_vv})
  
      s_0_val = 0
      s_1T_val = np.array([1, 0, 1, 0, 1, 1, 0, 1, 0, 1])
      Gamma_val = np.array([[0.1, 0.9], [0.9, 0.1]])
  
      exp_res = np.log(p_S_0[s_0_val])
      s_prev = s_0_val
      for s in s_1T_val:
          exp_res += np.log(Gamma_val[s_prev, s])
          s_prev = s
  
      S_0T_logp = sum(v.sum() for v in logp_parts.values())
      S_0T_logp_fn = pytensor.function(
          [s_0_vv, s_1T_vv, Gamma_at], S_0T_logp
      )
      res = S_0T_logp_fn(s_0_val, s_1T_val, Gamma_val)
  
      assert res == pytest.approx(exp_res)
  
imports: import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  from pytensor import Mode
  from pytensor.raise_op import assert_op
  from pytensor.scan.utils import ScanArgs
  from scipy import stats
  from pymc.logprob.abstract import _logprob_helper
  from pymc.logprob.basic import conditional_logp, logp
  from pymc.logprob.scan import construct_scan, convert_outer_out_to_in, get_random_outer_outputs
  from pymc.testing import assert_no_rvs
label_desc: Use image node_id 5 for calling a global function with example usage: test_initial_values() and returns: S_t