Optimal varies with imposed demands (load, speed, surface, fatigue, visual cues, stance width, pelvic position, hip joint shape, etc.). Squatting is not as simple as knees out being better than knees in or toes out being better than toes straight.
Variability is the ideal. It would be desirable to be able squat in many different ways and many different foot positions under varying circumstances.
There is never one ideal. That’s like saying there’s one ideal posture, one way to sit, one way to have sex, or one way to throw a ball.
In fact, we know that because of the noise built into the nervous system we can’t duplicate the same motion no matter how hard we try even if it looks the same to the naked eye.
With practice and good coaching, you will determine the optimal for the circumstances and the individual.