code: def _split_document(
      id,
      doc,
      question,
      answers,
      answer_starts,
      has_answer,
      ignore_impossible,
      max_character_length,
      min_overlap,
  ):
      pieces = []
      min_overlap = math.floor(max_character_length * min_overlap)
      if has_answer or not ignore_impossible:
          n_pieces = 1 + math.ceil(
              max(0, len(doc) - max_character_length)
              / (max_character_length - min_overlap)
          )
          overlap = (
              math.floor(
                  (n_pieces * max_character_length - len(doc))
                  / (n_pieces - 1)
              )
              if n_pieces > 1
              else 0
          )
          for n in range(n_pieces):
              start, end = (
                  n * (max_character_length - overlap),
                  (n + 1) * (max_character_length - overlap) + overlap,
              )
              answers, answer_starts, piece_has_answer = _shift_answers(
                  answers, answer_starts, start, end
              )
              pieces.append(
                  {
                      "id": id,
                      "doc": doc[start:end],
                      "question": question,
                      "answers": answers,
                      "answer_starts": answer_starts,
                      "has_answer": str(
                          has_answer and piece_has_answer
                      ),
                  }
              )
      return pieces
  
imports: import json
  import math
  from random import choice
  from typing import List, Optional
  from pytext.data.sources.data_source import DataSource, generator_property, JSONString, SafeFileWrapper
  from pytext.data.sources.tsv import TSV
  from pytext.utils.file_io import PathManager
  from pytext.utils.path import get_absolute_path
label_desc: Use image node_id 2 for calling a global function with example usage: _split_document(id, doc, question, answers, answer_starts, has_answer, ignore_impossible, max_character_length, min_overlap) and returns: pieces