Generalized twisted group rings