I guess you’ve wrapped your Dataset into a Subset (or a similar object, which would use specific indices), which contain invalid indices.
Could you check the length of the original Dataset and make sure the split indices are valid?