Create dataset from a python list of path

Good day to all.
I’m currently building a NLP model for document classification.
I have limited amount of computation power and storage, so I was wondering if it was possible to create a pytorch dataset from a python list of path, where every path leads to a different document.
I apologise if my question is not clear enough, and am prepared to give any more information that could be helfpful.
Thank you for your time.
Camille

Follow this, it is done for semantic segmentation. I think a similar thing can be worked out for your case.