You could use sklearn.model_selection.train_test_split with the stratify argument.
This would return indices for the training and validation dataset, which you could then pass to a Subset or SubsetRandomSampler.