I am using Jupyter notebook to simulate this. Here is the minimal reproducible example. Since my input and ouput are of the shape [1700, 402] and [1700,] I used the similar size here.
import torch
import numpy
from torch.utils.data import Dataset, DataLoader
import pdb

# dataset class
class data(Dataset):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        self.len = self.x.shape[0]

    def __getitem__(self, idx):
        return self.x[idx], self.y[idx]

    def __len__(self):
        return self.len

if __name__ == "__main__": 
    device = torch.device("cuda" if torch.cuda.is_available() else "cpu") 
    x = numpy.random.rand(1700,402)
    y = numpy.random.rand(1700)
    dataset = data(torch.Tensor(x),torch.Tensor(y))
    print('the length of the dataset = ', len(dataset))
    
    print ('before loader')
    data_loader = DataLoader(dataset, batch_size = 50, shuffle = True, pin_memory=True, num_workers = 1)
    print ('after loader')
    
    for idxs, (xx, yy) in enumerate(data_loader):
        xx, yy = xx.to(device), yy.to(device)
        print ('idx: {} x: {} y: {}'.format(idxs, xx, yy))

This time, the error is not shown however, the notebook gets stuck without displaying anything . It does print ‘after loader’ after which it gets stuck until I restart the kernel. It works perfectly fine if I set num_workers = 0.
Note: the brokern pipe error is still consistent with my original case.