Gutenberg Blocks: how to determine an index of the current inner block?

A save component is intended to save static HTML, and can rely only on the blocks attribute. No interactivity, no local state, no AJAX requests, etc, just block attributes.

If you achieve what you’re trying to do you’ll immediately run into a new problem with block validation failure. You cannot use the save component to figure out this information. Figure it out somewhere else and store it as an attribute, ideally in the edit component.