code: def format_sentences(paragraphs: list, nlp_hy: Pipeline) -> list:
      """
      Takes a list of paragraphs and returns a list of sentences,
      where each sentence is a list of tokens along with their respective entity tags.
      """
      sentences = []
      for paragraph in tqdm(paragraphs):
          doc = nlp_hy(
              filter_unicode_broken_characters(paragraph["text"])
          )
          for sentence in doc.sentences:
              sentence_ents = []
              entity = []
              for token in sentence.tokens:
                  label = get_label(
                      token.start_char,
                      token.end_char,
                      paragraph["labels"],
                  )
                  if label:
                      entity.append(token.text)
                      if token.end_char == label[1]:
                          sentence_ents.append(
                              {"tokens": entity, "tag": label[2]}
                          )
                          entity = []
                  else:
                      sentence_ents.append(
                          {"tokens": [token.text], "tag": "O"}
                      )
              sentences.append(sentence_ents)
      return sentences
  
file_path: stanza/stanza/utils/datasets/ner/convert_hy_armtdp.py
imports: import argparse
  import os
  import json
  import re
  import stanza
  import random
  from tqdm import tqdm
  from stanza import DownloadMethod, Pipeline
  import stanza.utils.default_paths
label_desc: Use image node_id 4 for calling a global function with example usage: format_sentences(paragraphs, nlp_hy) and returns: sentences