Adaptive Sampled Softmax with Inverted Multi-Index: Methods, Theory and Applications