Finally, I could reproduce the error. The failing depends on the size sz and I think it is not a good way to create images globally, wrap them with a Dataset and then fork them into multiple processes.
I think it is better to produce tensors at __getitem__. And try to change num_workers=2, 4, 8
The following works for me:
import torch
from torch.utils.data import Dataset, DataLoader
    

class VarSizeImages(Dataset):
    
    def __init__(self):
        self.sz = 100000
        self.images = []
        for i in range(self.sz):
            size = torch.randint(10, 20, size=(2, ), dtype=torch.long)
            img = torch.rand(tuple(size.numpy()))
            self.images.append(img)
            
    def __len__(self):
        return self.sz
    
    def __getitem__(self, idx):
        img = self.images[idx]
        label = torch.randint(0, 2, size=(1, ), dtype=torch.long).item()
        return img, label
        
def my_collate(batch):
    return [(dp[0], torch.tensor(dp[1])) for dp in batch]

ds = VarSizeImages()

loader = DataLoader(ds, batch_size=10, shuffle=True, num_workers=2, pin_memory=True, collate_fn=my_collate)

for batch in loader:
    pass