It’s rather difficult to understand what it does without having the Pandas DataFrame (which I cannot share, I guess). But here’s the class:
class Data(Dataset):

    def __init__(self, mode, df, img_dir, site, transform):
        self.mode = mode
        self.df = df
        self.img_dir = img_dir
        self.site = site
        self.transform = transform
    
    def path_channel(self, channel, idx):
        experiment = self.df.loc[self.df.index[idx], 'experiment']
        plate = self.df.loc[self.df.index[idx], 'plate']
        well = self.df.loc[self.df.index[idx], 'well']

        path = os.path.join(self.img_dir, experiment, f'Plate{plate}', 
                            f'{well}_s{self.site}_w{channel}.png')
        
        return path
    
    def __getitem__(self, idx):
        print(idx)  # With 1 process and batch size 1, printed twice (different items)

        # Iterate over channels of one image (from file)
        all_channels = [np.array(Image.open(self.path_channel(ch, idx)), 
                                dtype=np.float32) for ch in range(1, 7)]
        img = np.stack([ch for ch in all_channels], axis=2)
        
        if self.mode == 'train':
            label = self.df.loc[self.df.index[idx], 'label'].astype('int32')

            return img, label
        elif self.mode == 'test':

            return img
    
    def __len__(self):
        return self.df.shape[0]