Added penalty_g_all_epoch fn in optim_toolbox, plus fns it calls elsewhere