def batch_encode(text, max_seq_len):
    for i in range(0, len(df["Text"].tolist()), batch_size):
        encoded_sent = tokenizer.batch_encode_plus(
            df["Text"][i : i + batch_size].tolist(),
            max_length=max_seq_len,
            add_special_tokens=True,
            padding="longest",
            return_attention_mask=True,
            pad_to_max_length=True,
            truncation=True,
            return_tensors="pt",
        )

        input_ids_train = encoded_sent["input_ids"].to(device)
        attention_masks_train = encoded_sent["attention_mask"].to(device)
        output = model(input_ids_train, attention_masks_train)

Try this. Your ploblem is that you are passing all the text to batch_encode