Learning to Tokenize for generative retrieval