Does the error message indicate which line this out-of-bound happens?
Also, could you put print statements after each line of code in the __getitem__ function? Then, we can find out where this is happening.