You could most likely create a mask using the non-special indices, apply it to the tensor, and sum it.
I’m not sure, how the “spacial” indices are defined and thus how complicated it would be to “find” them.