@ptrblck
Thanks for the reply, I will investigate more on that.
I created a dummy example like what you did before,
class MyDataset(Dataset):
    def __init__(self):
        self.data = torch.ones(10)
        self.num = 10

    def __getitem__(self, index):
        self.data[index] = self.get_sample()
        return self.data[index]

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

    def set_sample(self, num):
        self.num = num

    def get_sample(self):
        return self.num

num_workers = 10
dataset = MyDataset()
loader = DataLoader(
    dataset,
    num_workers=num_workers,
    shuffle=False
)
for idx, data in enumerate(loader):
    if idx == 3:
        loader.dataset.set_sample(12)
    print(f'{idx}  {data}, num_workers: {num_workers}')

print('-----------------------------------------------')

for idx, data in enumerate(loader):
    if idx == 3:
        loader.dataset.set_sample(12)
    print(f'{idx}  {data}, num_workers: {num_workers}')


num_workers =1
dataset = MyDataset()
loader = DataLoader(
    dataset,
    num_workers=num_workers,
    shuffle=False
)

print('-----------------------------------------------')
for idx, data in enumerate(loader):
    if idx == 3:
        loader.dataset.set_sample(12)
    print(f'{idx}  {data}, num_workers {num_workers}')
print('-----------------------------------------------')

for idx, data in enumerate(loader):
    if idx == 3:
        loader.dataset.set_sample(12)
    print(f'{idx}  {data}, num_workers {num_workers}')



I expect data[3] to data [9] be 12 but did’nt happen.