Secure and Reliable D2D Communications with Active Attackers: A Game-Theoretic Perspective and Machine Learning Approaches