Can someone give an idea on how to implement k-means clustering loss in pytorch?

Also I am using Pytorch nn.mse() loss. Is there a way to add L2 reguarization to this term. In short, if I want to use L2-Reg. loss.