Gradient-based bilevel optimization for multi-penalty Ridge regression through matrix differential calculus