Using GridSearchCV for custom kernel SVM in scikit-learn
Look at the source code and modify it to meet your conditions.

https://github.com/scikit-learn/scikit-learn/blob/ab93d65/sklearn/model_selection/_search.py#L685