Bled_Clement:

Can someone explain to me what the benefit would be of writing the load_dataset() function into a class?


load_dataset would be a function, which returns the DataLoader not a class.
I would claim it depends on your coding style and wrapping the DataLoader creation into a function might allow you to move it into another file more easily.



 Bled_Clement:

but it seems that most codebases use class LoaderName(Dataset)


This class definition would be used to create a custom Dataset as described here. In your example you are using ImageFolder so wouldn’t need the custom Dataset class.