Generalized ergodic inequalities and ergodic theorems