I modify your example a little bit to show the problem.
from multiprocessing import Manager
import torchvision
import torch
from torch.utils.data import Dataset, DataLoader
from PIL import Image

class MyDataset(Dataset):
    def __init__(self, shared_dict, length):
        self.shared_dict = shared_dict
        self.length = length
        self.scale=torchvision.transforms.Resize([321,321])
        self.ToTensor=torchvision.transforms.ToTensor()
    def __getitem__(self, index):
        if index not in self.shared_dict:
            print('Adding {} to shared_dict'.format(index))
            self.shared_dict[index] = Image.open('test_img.png')#torch.FloatTensor([index])

        return self.ToTensor(self.scale(self.shared_dict[index]))
    def __len__(self):
        return self.length


# Init
manager = Manager()
shared_dict = manager.dict()
dataset = MyDataset(shared_dict, length=100)





loader = DataLoader(
    dataset,
    batch_size=2,
    num_workers=6,
    shuffle=True,
    pin_memory=True
)

# First loop will add data to the shared_dict
for x in loader:
    
    pass

# The second loop will just get the data
for x in loader:
    pass