Added train_on_subset function to gather data in CUDA using indices for segmentation.