I don’t think you need a custom dataloader and using a multiprocessing queue in the dataset should suffice:
# Initialize a queue.
import multiprocessing as mp
q = mp.Queue()


# Pass the queue to the dataset
class MyDataset(Dataset):
    def __init__(self, q):
        self.data = np.random.randint(0, 100, (10, 2, 2))
        self.max_id = np.ones(len(self.data), dtype=np.int16)
        self.q = q
        q.put(self.max_id)


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


    def __getitem__(self, idx):
        self.max_id[idx] = np.max(self.data[idx, :, :])
        q.put(self.max_id)
        return self.data[idx, :, :]

# Then in the main process

def main():
    np.random.seed(42)
    torch.manual_seed(42)
    dataset = MyDataset(q)
    loader = DataLoader(dataset, batch_size=4, shuffle=True, num_workers=1)
    loader_iter = iter(loader)

    print(f'Initial State: {dataset.max_id}')

    batch = next(loader_iter)

    max_id = q.get()
    print(f'After num_worker=1: {max_id}')