code: def test_kiepredictor(
      mock_pdf, mock_vocab, assume_straight_pages, straighten_pages
  ):
      det_bsize = 4
      det_predictor = DetectionPredictor(
          PreProcessor(output_size=(512, 512), batch_size=det_bsize),
          detection.db_mobilenet_v3_large(
              pretrained=True,
              pretrained_backbone=False,
              input_shape=(512, 512, 3),
              assume_straight_pages=assume_straight_pages,
          ),
      )
  
      reco_bsize = 16
      reco_predictor = RecognitionPredictor(
          PreProcessor(
              output_size=(32, 128),
              batch_size=reco_bsize,
              preserve_aspect_ratio=True,
          ),
          recognition.crnn_vgg16_bn(
              pretrained=False,
              pretrained_backbone=False,
              vocab=mock_vocab,
          ),
      )
  
      doc = DocumentFile.from_pdf(mock_pdf)
  
      predictor = KIEPredictor(
          det_predictor,
          reco_predictor,
          assume_straight_pages=assume_straight_pages,
          straighten_pages=straighten_pages,
          detect_orientation=True,
          detect_language=True,
      )
  
      if assume_straight_pages:
          assert predictor.crop_orientation_predictor is None
      else:
          assert isinstance(
              predictor.crop_orientation_predictor, NestedObject
          )
  
      out = predictor(doc)
      assert isinstance(out, KIEDocument)
      assert len(out.pages) == 2
      # Dimension check
      with pytest.raises(ValueError):
          input_page = (255 * np.random.rand(1, 256, 512, 3)).astype(
              np.uint8
          )
          _ = predictor([input_page])
  
      orientation = 0
      assert out.pages[0].orientation["value"] == orientation
      language = "unknown"
      assert out.pages[0].language["value"] == language
  
imports: import numpy
  import pytest
  from doctr import models
  from doctr.file_utils import CLASS_NAME
  from doctr.io import Document, DocumentFile
  from doctr.io.elements import KIEDocument
  from doctr.models import detection, recognition
  from doctr.models.detection.predictor import DetectionPredictor
  from doctr.models.detection.zoo import detection_predictor
  from doctr.models.kie_predictor import KIEPredictor
  from doctr.models.predictor import OCRPredictor
  from doctr.models.preprocessor import PreProcessor
  from doctr.models.recognition.predictor import RecognitionPredictor
  from doctr.models.recognition.zoo import recognition_predictor
  from doctr.utils.repr import NestedObject
label_desc: Use image node_id 3 for calling a global function with example usage: test_kiepredictor(mock_pdf, mock_vocab, assume_straight_pages, straighten_pages) without return types