code: def detect_document_block_types(
      doc,
      blocks: List[Page],
      layoutlm_model,
      batch_size=settings.LAYOUT_BATCH_SIZE,
  ):
      encodings, metadata, sample_lengths = get_features(doc, blocks)
      predictions = predict_block_types(
          encodings, layoutlm_model, batch_size
      )
      block_types = match_predictions_to_boxes(
          encodings,
          predictions,
          metadata,
          sample_lengths,
          layoutlm_model,
      )
      assert len(block_types) == len(blocks)
      return block_types
  
imports: from concurrent.futures import ThreadPoolExecutor
  from typing import List
  from transformers import LayoutLMv3ForTokenClassification
  from marker.bbox import unnormalize_box
  from transformers.models.layoutlmv3.image_processing_layoutlmv3 import normalize_box
  import io
  from PIL import Image
  from transformers import LayoutLMv3Processor
  import numpy
  from marker.settings import settings
  from marker.schema import Page, BlockType
  import torch
  from math import isclose
label_desc: Use image node_id 2 for calling a global function with example usage: detect_document_block_types(doc, blocks, layoutlm_model, batch_size) and returns: block_types