How can I implement SVM in CNN architecture

I know in keras, we can add the kernal regularizer to implement SVM with CNN. How can we do that in Pytorch? How can I modify the last layer so it includes SVM ?

Or is there any alternative way to define a SVM class similar to CNN architecture ?