I want to find a function

Excuse me my friends
In the past I used Keras to finish my NLP tasks.
recently I turned to Pytorch
The thing I want to ask is
In keras I use
tokenizer.fit_on_texts(texts + pos_en1 + pos_en2)
to build a vocab of str and index .and then I could use
texts_to_sequence to change my texts and position into index
Is there any function in pytorch I could do the same things?
Thank you for answering