Using PyTensor.scan to loop over multidimensional array

Thank you for the quick reply!
That makes a lot of sense. The scan implementation I used was with an older version of the model (just one dimensional) and I used the scan(fn: lambda (myfunction), sequences= i ).
But then I got the error, that one of my variable was a random variable and scan couldn’t handle that.
Now I don’t understand the syntax of scan good enough to implement the above code snipped in a useful way. For example, how do I tell scan to only loop over one dimension of a PyTensor tensor?