Intelligent Random Access Framework for Massive and Ultra-Reliable Low Latency IoT Communications