How to finetune models with own dataset in tensorflow?

I am trying to follow the tutorial here, but I want to use my own dataset.
I have stored the texts and the labels in a pandas dataset named train. Which has only two columns text, and labels.
I have tried the following code

train_tokenized = tokenizer(list(train.text)), padding="max_length", truncation=True, return_tensors="tf")
train_features = {x: train_tokenized[x] for x in tokenizer.model_input_names}
train_tf_data =, train.labels))
train_tf_data = train_tf_data.batch(8)
), epochs=3)

But it gives me ValueError: Unsupported type BatchEncoding returned by IteratorSpec._serialize