PyTorch training scripts freeze when preprocessing_num_workers > 1
### System Info

transformers 4.24.0
datasets 2.7.1

Dockerfile: https://github.com/aws/deep-learning-containers/blob/master/pytorch/training/docker/1.12/py3/cu113/Dockerfile.gpu

### Who can help?

@sgugger, @patil-sura

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

### Local Repro

`python3.8 run_mlm.py --dataloader_drop_last True --dataset_config_name wikitext-103-v1 --dataset_name wikitext --do_train True --fp16 True --max_seq_length 512 --model_name_or_path bert-base-uncased --num_train_epochs 16 --per_device_train_batch_size 32 --preprocessing_num_workers 12
`
### AWS Repro

`
!pip install sagemaker
from sagemaker.pytorch import PyTorch
PyTorch(
framework_version='1.12',
py_version="py38",
instance_type="ml.p4d.24xlarge",
distribution={"pytorchddp": {"enabled": True}},
source_dir="examples/pytorch/language-modeling",
entry_point="run_mlm.py",
hyperparameters={
    'dataset_name': 'wikitext',
    'dataset_config_name': 'wikitext-103-v1',
    'do_train': True,
    'fp16': True,
    'model_name_or_path': 'bert-base-uncased',
    'num_train_epochs': 10,
    'per_device_train_batch_size': 32,
    'preprocessing_num_workers': 12,
},
).fit()
`

### Expected behavior

Training to completion without stalls/freezes at data preprocessing.

Currently the training stalls with the last log line being:
```
Grouping texts in chunks of 512
```
Any update here ?<|||||>This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.