You could use sklearn.model_selection.train_test_split 23 with the stratify option to create the desired sample indices.
Once you have the indices, create the training and validation datasets by wrapping the whole dataset into Subsets and passing the corresponding indices to them.