dataset_with_ocr = updated_dataset.map(get_ocr_words_and_boxes, batched=True, batch_size=2)

Preprocessing text data
Once we have applied OCR to the images, we need to encode the text part of the dataset to prepare it for the model.
This involves converting the words and boxes that we got in the previous step to token-level input_ids, attention_mask,
token_type_ids and bbox. For preprocessing text, we'll need the tokenizer from the processor.

tokenizer = processor.tokenizer