Learning-Based Distributed Random Access for Multi-Cell IoT Networks with NOMA