You can't use a Tokenizer for this because the Tokenizer indexing starts at 1, and not 0. You can use tf.where:
import tensorflow as tf
y = ['class3', 'class1', 'class1', 'class2', 'class3', 'class1', 'class2']
names = ["class1", "class2", "class3"]
labeler = lambda x: tf.where(tf.equal(x, names))
dataset = tf.data.Dataset.from_tensor_slices(y).map(labeler)
next(iter(dataset))
<tf.Tensor: shape=(1, 1), dtype=int64, numpy=array([[2]], dtype=int64)>
If you want to do it on a list or Numpy array you can use Scikit-Learn:
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
le.fit_transform(y)
array([2, 0, 0, 1, 2, 0, 1], dtype=int64)
As I said previously, your implementation started indexing at 1:
[[2], [1], [1], [3], [2], [1], [3]]
This crashes Keras when it measures loss and metrics. It will return nan because you'll have three final neurons, but targets srtating from the 2nd index to the 4th. tl;dr don't use indexing that starts at 1 with Keras.