Dataloader for custom dataset in Hierarchical Deep CNN

Hello Community, I want to implement hierarchical deep CNN with a custom dataset. How do I write a data loader for the same? I want to use both coarse as well as fine labels. The model will predict the coarse label first and then the fine label based on the class of the coarse label.

I would appreciate it if you help me write the code. I am new to Pytorch.

Thanks & Regards.