Solved by songqsh in post #4 
              
              
                Here is the code without nditer, provided from stackoverflow. 
#alternative for nditer, but for both tensor and ndarray
def deep_iter(data, ix=tuple()):
    try:
        for i, element in enumerate(data):
            yield from deep_iter(element, ix + (i,))
    except:
        yield ix, data

#do av…