code: def overlap_handler(
      current_annotation, annotation, text, multi_label
  ):
      """
      Scenarios:
          <> --> current_annotation
          [] --> annotation
  
      1) < [ > ]
      2) [ < > ]
      3) < [ ] >
      """
      if current_annotation["start"] <= annotation["start"]:
          first, second = current_annotation, annotation
      else:
          first, second = annotation, current_annotation
  
      final_delimiter = min(first["end"], second["end"])
      final_label = (
          second["label"]
          if (second["end"] > first["end"])
          else first["label"]
      )
      overlapping_text = text[second["start"] : final_delimiter]
      end = max(first["end"], second["end"])
  
      first_chunk = {
          "start": first["start"],
          "end": second["start"],
          "label": first["label"],
          "text": text[first["start"] : second["start"]],
      }
  
      if multi_label:
          second_label = first["label"] | second["label"]
      else:
          if first["label"] != second["label"] and (
              len(overlapping_text.strip()) > 1
          ):
              warnings.warn(
                  "Found overlapping annotations: {} and {}. \n"
                  "Consider setting `multi_label_sequences` to `True` in your config.".format(
                      annotation, current_annotation
                  )
              )
          spacy_tokens = get_spacy()(text)
          spacy_token_starts = [token.idx for token in spacy_tokens]
          if second["label"] in spacy_token_starts:
              second_label = second["label"]
          elif final_delimiter in spacy_token_starts:
              second_label = first["label"]
          else:
              second_label = first["label"]
  
      second_chunk = {
          "start": second["start"],
          "end": final_delimiter,
          "label": second_label,
          "text": overlapping_text,
      }
  
      third_chunk = {
          "start": final_delimiter,
          "end": end,
          "label": final_label,
          "text": text[final_delimiter:end],
      }
      chunks = [first_chunk, second_chunk, third_chunk]
      chunks = [c for c in chunks if c["start"] != c["end"]]
      return chunks
  
file_path: finetune/finetune/encoding/sequence_encoder.py
imports: import warnings
  import numpy
  from finetune.encoding.input_encoder import get_spacy
label_desc: Use image node_id 8 for calling a global function with example usage: overlap_handler(current_annotation, annotation, text, multi_label) and returns: chunks