Primal Method for ERM with Flexible Mini-batching Schemes and Non-convex Losses