Solved by noornk in post #5 
              
              
                With a great amount of shame, I declare that in MyDataset, I’ve passed the parameter “idx” as index in getitem(), but I’ve used a new parameter “index” in the function! I’m sorry for wasting your time!