I’m not sure, if this covers your whole use case, but you could just get the desired number of samples from your dataset and process them in __getitem__.
Here is a small example:
class MyDataset(Dataset):
    def __init__(self, nb_samples):
        self.images = torch.randn(100, 3, 24, 24)
        self.audio = torch.randn(100, 1024, 12)
        self.nb_samples = nb_samples
        
    def __getitem__(self, index):
        # Load all nb_samples
        images = self.images[index*self.nb_samples:index*self.nb_samples+self.nb_samples]
        audio_specs = self.audio[index*self.nb_samples:index*self.nb_samples+self.nb_samples]
        
        # Transform
        
        # Sum samples
        x1 = torch.sum(images)
        x2 = torch.sum(audio_specs)
        
        return x1, x2
        
        
    def __len__(self):
        return len(self.images) / self.nb_samples - self.nb_samples


dataset = MyDataset(2)
img_sum, audio_sum = dataset[0]

Currently adjacent samples are used. Let me know, if you need another strategy.