Hey -
This could be done in the following way -
class VideoDataset(torch.utils.data.Dataset):
    def __init__(self, path_to_npy_files):
        self.video_files = os.listdir(path_to_npy_files)
        '''
       Anything else here
        '''

    def __getitem__(self, idx):
        video_frames = []

        video_file = self.video_files[idx]
        video = numpy.load(video_file)

        image_tensor = torch.from_numpy(video[0]).permute(0, 3, 1, 2) # I am assuming video is of shape D, H, W, C. If not so, please change accordingly
         
        label = torch.tensor(video[1], dtype = torch.long) # I assume you are classifying video frames
        return video_tensor, label    

    def __len__(self):
        return len(self.video_files)


I am not sure what exactly is in the npz file. From what I understood, npz file stores an array, who’s first entry is an array which contains the images and second is the class, and I have wriiten the dataset accordingly, If this is not the case, then please change accordingly. only the video[0] and video[1] part would change.
The dataloader can be created as follows -
def GetDataloader(path_to_npy_files, batch_size, num_workers):
    dataset = VideoDataset(path_to_npy_files)
    dataloader = torch.utils.data.DataLoader(dataset = dataset, batch_size=batch_size, num_workers = num_workers, shuffle=True)

PS - Please excuse any indentation errors, I have directly typed the code here.