How to Convert a String to LongTensor, and Back?

In Karpathy’s minGPT, he lists the dataloader as needing to return individual examples of LongTensors, but how do I convert String to and from LongTensors?

If you could give some examples of the kind of conversion that you are after, then I can try finding a way to do that.