code: def batch_inference(rgb_images, bboxes, words, model):
      encoding = processor(
          rgb_images,
          text=words,
          boxes=bboxes,
          return_tensors="pt",
          truncation=True,
          padding="max_length",
          max_length=128,
      )
  
      encoding["pixel_values"] = encoding["pixel_values"].to(
          model.dtype
      )
  
      with torch.inference_mode():
          for k in [
              "bbox",
              "input_ids",
              "pixel_values",
              "attention_mask",
          ]:
              encoding[k] = encoding[k].to(model.device)
          outputs = model(**encoding)
          logits = outputs.logits
  
      predictions = logits.argmax(-1).squeeze().tolist()
      if isinstance(predictions, int):
          predictions = [predictions]
      predictions = [model.config.id2label[p] for p in predictions]
      return predictions
  
file_path: pdf-to-markdown/marker/ordering.py
imports: from copy import deepcopy
  from typing import List
  import torch
  import sys, os
  from marker.extract_text import convert_single_page
  from transformers import LayoutLMv3ForSequenceClassification, LayoutLMv3Processor
  from PIL import Image
  import io
  from marker.schema import Page
  from marker.settings import settings
label_desc: Use image node_id 3 for calling a global function with example usage: batch_inference(rgb_images, bboxes, words, model) and returns: predictions