code: def test_ScanArgs_basics_mit_sot():
      srng = pt.random.RandomStream()
  
      N_pt = pt.iscalar("N")
      N_pt.tag.test_value = 10
      M_pt = pt.iscalar("M")
      M_pt.tag.test_value = 2
  
      mus_pt = pt.matrix("mus")
      mus_pt.tag.test_value = np.stack(
          [np.arange(0.0, 10), np.arange(0.0, -10, -1)], axis=-1
      ).astype(pytensor.config.floatX)
  
      sigmas_pt = pt.ones((N_pt,))
      sigmas_pt.name = "sigmas"
  
      pi_0_rv = srng.dirichlet(pt.ones((M_pt,)), name="pi_0")
      Gamma_rv = srng.dirichlet(pt.ones((M_pt, M_pt)), name="Gamma")
  
      S_0_rv = srng.categorical(pi_0_rv, name="S_0")
  
      def scan_fn(mus_t, sigma_t, S_tm2, S_tm1, Gamma_t):
          S_t = srng.categorical(Gamma_t[S_tm2], name="S_t")
          Y_t = srng.normal(mus_t[S_tm1], sigma_t, name="Y_t")
          return S_t, Y_t
  
      (S_rv, Y_rv), scan_updates = pytensor.scan(
          fn=scan_fn,
          sequences=[mus_pt, sigmas_pt],
          non_sequences=[Gamma_rv],
          outputs_info=[
              {"initial": pt.stack([S_0_rv, S_0_rv]), "taps": [-2, -1]},
              {},
          ],
          strict=True,
          name="scan_rv",
      )
      # Adding names should make output easier to read
      Y_rv.name = "Y_rv"
      # This `S_rv` outer-output is actually a `Subtensor` of the "real" output
      S_rv = S_rv.owner.inputs[0]
      S_rv.name = "S_rv"
      mus_in = Y_rv.owner.inputs[1]
      mus_in.name = "mus_in"
      sigmas_in = Y_rv.owner.inputs[2]
      sigmas_in.name = "sigmas_in"
  
      scan_args = ScanArgs.from_node(Y_rv.owner)
  
      test_v = scan_args.inner_in_mit_sot[0][1]
      field_info = scan_args.find_among_fields(test_v)
  
      assert field_info.name == "inner_in_mit_sot"
      assert field_info.index == 0
      assert field_info.inner_index == 1
      assert field_info.agg_index == 3
  
      rm_info = scan_args._remove_from_fields(pt.ones(2))
      assert rm_info is None
  
      rm_info = scan_args._remove_from_fields(test_v)
  
      assert rm_info.name == "inner_in_mit_sot"
      assert rm_info.index == 0
      assert rm_info.inner_index == 1
      assert rm_info.agg_index == 3
  
file_path: pytensor/tests/scan/test_utils.py
imports: from copy import copy
  import numpy
  import pytest
  import pytensor
  from pytensor import tensor
  from pytensor.scan.utils import ScanArgs
label_desc: Use image node_id 4 for calling a global function with example usage: test_ScanArgs_basics_mit_sot() and returns: S_t,  Y_t