code: def test_large_model_pt_layoutlm_chunk(self):
      tokenizer = AutoTokenizer.from_pretrained(
          "impira/layoutlm-document-qa",
          revision="3dc6de3",
          add_prefix_space=True,
      )
      dqa_pipeline = pipeline(
          "document-question-answering",
          model="impira/layoutlm-document-qa",
          tokenizer=tokenizer,
          revision="3dc6de3",
          max_seq_len=50,
      )
      image = INVOICE_URL
      question = "What is the invoice number?"
  
      outputs = dqa_pipeline(image=image, question=question, top_k=2)
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              {
                  "score": 0.9999,
                  "answer": "us-001",
                  "start": 16,
                  "end": 16,
              },
              {
                  "score": 0.9998,
                  "answer": "us-001",
                  "start": 16,
                  "end": 16,
              },
          ],
      )
  
      outputs = dqa_pipeline(
          [
              {"image": image, "question": question},
              {"image": image, "question": question},
          ],
          top_k=2,
      )
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              [
                  {
                      "score": 0.9999,
                      "answer": "us-001",
                      "start": 16,
                      "end": 16,
                  },
                  {
                      "score": 0.9998,
                      "answer": "us-001",
                      "start": 16,
                      "end": 16,
                  },
              ]
          ]
          * 2,
      )
  
      word_boxes = list(
          zip(*apply_tesseract(load_image(image), None, ""))
      )
  
      # This model should also work if `image` is set to None
      outputs = dqa_pipeline(
          {
              "image": None,
              "word_boxes": word_boxes,
              "question": question,
          },
          top_k=2,
      )
      self.assertEqual(
          nested_simplify(outputs, decimals=4),
          [
              {
                  "score": 0.9999,
                  "answer": "us-001",
                  "start": 16,
                  "end": 16,
              },
              {
                  "score": 0.9998,
                  "answer": "us-001",
                  "start": 16,
                  "end": 16,
              },
          ],
      )
  
file_path: H2O/h2o_flexgen/benchmark/third_party/transformers/tests/pipelines/test_pipelines_document_question_answering.py
imports: import unittest
  from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available
  from transformers.pipelines import pipeline
  from transformers.pipelines.document_question_answering import apply_tesseract
  from transformers.testing_utils import nested_simplify, require_detectron2, require_pytesseract, require_tf, require_torch, require_vision, slow
  from .test_pipelines_common import ANY, PipelineTestCaseMeta
label_desc: Use image node_id 7 for calling the DocumentQuestionAnsweringPipelineTests obj's underlying member method code with example usage: obj.test_large_model_pt_layoutlm_chunk() without return types