Depending on the problem, you need TransformerEncoder or Transformer (encoder + decoder). Training the model is similar to the training function in the tutorial. For non-NLP problems, you need to figure out how to calculate the loss. Unless you show more details about your problem, I cannot give more help. The tutorial is a word-language-model problem and, more concise, predicting the next word following a sequence.