Each patient would get an index (similar to a target) and you could pass it to the GroupShuffleSplit to get the indices for the train and validation split based on the patients.
E.g. if patient_1 has 1 image and patient_2 2 images, you could pass the groups as: [0, 1, 1].