How to create a custom Dataset and DataLoader with reference table

I have a reference.csv file that has three columns: Type, Class, and Path. Here are the first 5 example rows:

    "Type","Class","Path"
    "train","A","./path1/001.jpg"
    "train","A","./path2/002.jpg"
    "test","C","./path3/003.jpg"
    "train","B","./path4/001.jpg"
    "test","B","./path5/002.jpg"
    ...

In a more viewer-friendly format:

    |----------------------|------------------|------------------|
    |         Type         |       Class      |       Path       |
    |----------------------|------------------|------------------|
    |        train         |         A        | ./path1/001.jpg  |
    |----------------------|------------------|------------------|
    |        train         |         A        | ./path2/002.jpg  |
    |----------------------|------------------|------------------|
    |        train         |         C        | ./path3/003.jpg  |
    |----------------------|------------------|------------------|
    |        test          |         B        | ./path4/001.jpg  |
    |----------------------|------------------|------------------|
    |        test          |         B        | ./path5/002.jpg  |
    |----------------------|------------------|------------------|

I want to create a Dataset class (torch.utils.data.Dataset) to read the images so I can use the DataLoader (torch.utils.data.DataLoader).

What is the correct way to create a custom Dataset and DataLoader using a reference table?