There are 46 benign (B) patients and 44 malignant (M) patients. Each patient has 4 images. I want to take 60% patient as train, 20% as valid and 20% for test. The split should always have been done patient-level, meaning images of the same patient should either belong to the train or test set but not be shared among them.
So Train – B: 28 patients + M: 26 patients
Valid- B: 9 patients  + M: 9 patients
Test- B: 9 patients + M: 9 patients
How to split the datasets in folder wise in pytorch?