A Python program to generate the Lagrangians for dark matter models