Safe machine learning-based perception via closed-loop analysis