Oh this is so much cleaner!
I will certainly soon try to time it to see performance, because there is way less operations, but there is creation of a big Tensor. Also I’ll put a comment if I manage to have a variation with a variable number of indices dimension (even though I think for my project it is alright because I think I only need for 3 dimensions)
Thank you a lot!