code: def _single_convert_to_finetune(
      *, document, dpi_norm=True, config={}
  ):
      context = get_context(
          document,
          dpi_norm,
          base_model=config.get("base_model", DocRep),
      )
      texts = []
      last_end = -1
      num_pages = len(document)
      for i, page in enumerate(document):
          page_obj = page["pages"][0]
          if i == num_pages - 1:
              texts.append(page_obj["text"])
          else:
              texts.append(page_obj["text"] + "\n")
          offset = page_obj["doc_offset"]
          assert (
              offset["start"] == last_end + 1
          ), "If ever this ceases to hold then we have a problem"
          last_end = offset["end"]
      return texts, context
  
file_path: finetune/finetune/target_models/document_labeling.py
imports: import warnings
  from finetune.target_models.sequence_labeling import SequenceLabeler, SequencePipeline
  from finetune.encoding.input_encoder import EncodedOutput
  from finetune.errors import FinetuneError
  from finetune.base_models import DocRep, LayoutLM, XDocBase
  from finetune.util.context_utils import get_context_doc_rep
label_desc: Use image node_id 2 for calling a global function with example usage: _single_convert_to_finetune() and returns: texts,  context