If your Dataset has the length 22, then the last index should be 21, which would also explain the IndexError.
Could you check the length of the Dataset via print(len(dataset))? I assume it would return a value which is larger than 22.
In that case, check the Dataset.__len__  method and make sure you are returning the right value for the length. 
Let me know, if this helps.