Yes, I have added the if-clause protection and it now works also with num_workers >0
Now I have just added a one line code to see the shape of the loaded data
but the output shape is <built-in method size of Tensor object at 0x0000013B77CE7900>
it seems that it is not loading the data properly . Is it?
def train(experiment_name='unet', resume=True):
    train_dataset=load_dataset(True,output_shape)

    width = train_dataset.roi_w
    height = train_dataset.roi_h
    num_cls = train_dataset.n_classes

    print('width',width)

    train_loader = DataLoader(train_dataset,#batch_size=cfg.UNET.BATCH_SIZE,
                              batch_size=2,
                              num_workers=2)
    for i, data in enumerate(train_loader, 0):
        inputs, grts = data

            #plt.figure()
            #plt.imshow(inputs, cmap=plt.cm.gray)
            #plt.show()
        print(inputs.size)
        print(grts.size)
if __name__ == '__main__':

    train() ```