code: def get_table_text_chunks_and_context(
      self,
      text: t.List[str],
      tables: t.List[DocumentTables],
      labels: t.List[DocumentSpans] = None,
  ) -> t.Dict[str, dict]:
      # The following items are 1 entry per-table.
      table_chunks_output = []  # Chunk objects
      table_context_output = []  # Context, formatted for tinetune
      table_doc_index_output = (
          []
      )  # The original document index for a table.
      table_text_output = []  # Text of the table only.
      table_labels_output = (
          []
      )  # Labels of the table only. With start and end to match the text
  
      # text_labels_output is 1 item per document.
      text_labels_output = []
  
      for i, (
          document_text,
          document_tables,
          document_labels,
      ) in enumerate(
          zip(text, tables, labels if labels else [None] * len(text))
      ):
          # These lists are to accumulate table labels and table chunks for a given document.
          document_table_labels = []
          document_table_chunks = []
  
          for page_tables in document_tables:
              for table in page_tables:
                  table_doc_offsets = table["doc_offsets"]
                  table_text_i = self.get_table_text(
                      document_text, table_doc_offsets
                  )
                  if table_text_i.strip() == "":
                      # Seems like the table model is occasionally outputting empty tables.
                      continue
                  table_doc_index_output.append(i)
                  table_text_output.append(table_text_i)
                  table_chunks_i = self.create_chunks_from_doc_offset(
                      table_doc_offsets
                  )
                  document_table_chunks.append(table_chunks_i)
                  table_context_output.append(
                      self.get_table_context(
                          doc_text=document_text,
                          table_text=table_text_i,
                          table=table,
                          table_chunks=table_chunks_i,
                      )
                  )
                  if document_labels is not None:
                      document_table_labels.append(
                          fix_spans(
                              document_labels,
                              table_chunks=table_chunks_i,
                              output_space_text=table_text_i,
                              input_space="document",
                              output_space="table",
                          )
                      )
          table_labels_output += document_table_labels
          table_chunks_output += document_table_chunks
  
          if self.drop_table_from_text_labels and labels is not None:
              text_labels_output.append(
                  self.remove_table_labels(
                      doc_labels=document_labels,
                      doc_chunks=document_table_chunks,
                      doc_text=document_text,
                  )
              )
          else:
              text_labels_output.append(document_labels)
      if labels is not None:
          output = {
              "doc_labels": text_labels_output,
              "table_labels": table_labels_output,
          }
      else:
          output = dict()
  
      return {
          **output,
          "table_text": table_text_output,
          "table_chunks": table_chunks_output,
          "table_context": table_context_output,
          "table_doc_i": table_doc_index_output,
          "doc_text": text,
      }
  
imports: import copy
  import functools
  import os
  import tempfile
  import typing
  import sys
  from finetune.base_models import TableRoBERTa
  from finetune.util.metrics import sequences_overlap
  from finetune.scheduler import Scheduler
  from finetune.encoding.input_encoder import BaseEncoder
  from finetune import SequenceLabeler
label_desc: Use image node_id 8 for calling the TableETL obj's underlying member method code with example usage: obj.get_table_text_chunks_and_context(text, tables, labels) and returns: dict