__getitem__(self, idx) is what gets called when you do the index operator ([idx]).
So dataset[idx] actually calls dataset.__getitem__(idx). You can of course also call __getitem__ directly, but it’s meant to be accessed through the [] operator.