Artificial Intelligence and Machine Learning for Autonomous Optimization and Control of Accelerators and Detectors