code: def fix_spans(
      spans: DocumentSpans,
      table_chunks: TableChunks,
      output_space_text: str,
      input_space: str,
      output_space: str,
  ) -> DocumentSpans:
      """
      convers a list of spans (anything with a start, end and optionally text, usually labels or context)
      between 2 character spaces (document and table)
  
      Will do 1 -> many splits when a span spreads across multiple chunks.
  
      Args:
          spans: The spans (labels or context) to move between the character spaces.
          chunk: The chunks a list of dicts including input_space and output_space keys.
          output_space_text: The text of the output space, used for validation.
          input_space: a key into chunks of the space the current spans are in.
          output_space: a key into chunks of the space to move the current spans
          strict: bool, whether to assert that every span is matched by at least one chunk.
  
      """
      spans_out = []
      for span in spans:
          for table_chunk in table_chunks:
              if sequences_overlap(span, table_chunk[input_space]):
                  spans_out.append(
                      _adjust_span_to_chunk(
                          span,
                          table_chunk,
                          output_space,
                          input_space,
                          output_space_text,
                      )
                  )
      return spans_out
  
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 3 for calling a global function with example usage: fix_spans(spans, table_chunks, output_space_text, input_space, output_space) and returns: spans_out