code: def extract_entities_from_sentence(ner_sent):
      # extracts all the entity dicts from the sentence
      # we assume that an entity cannot span across sentences
      segs = ner_sent.findall("./{%s}seg" % NAMESPACE)
      sent_entities = {}
      for i, seg in enumerate(segs):
          ent_id = get_node_id(seg)
          targets = [
              ptr.get("target")
              for ptr in seg.findall("./{%s}ptr" % NAMESPACE)
          ]
          orth = seg.findall(
              "./{%s}fs/{%s}f[@name='orth']/{%s}string"
              % (NAMESPACE, NAMESPACE, NAMESPACE)
          )[0].text
          ner_type = seg.findall(
              "./{%s}fs/{%s}f[@name='type']/{%s}symbol"
              % (NAMESPACE, NAMESPACE, NAMESPACE)
          )[0].get("value")
          ner_subtype_node = seg.findall(
              "./{%s}fs/{%s}f[@name='subtype']/{%s}symbol"
              % (NAMESPACE, NAMESPACE, NAMESPACE)
          )
          if ner_subtype_node:
              ner_subtype = ner_subtype_node[0].get("value")
          else:
              ner_subtype = None
          entity = {
              "ent_id": ent_id,
              "index": i,
              "orth": orth,
              "ner_type": ner_type,
              "ner_subtype": ner_subtype,
              "targets": targets,
          }
          sent_entities[ent_id] = entity
      cleared_entities = clear_entities(sent_entities)
      return cleared_entities
  
imports: import argparse
  import json
  import os
  import random
  import tarfile
  import tempfile
  from tqdm import tqdm
label_desc: Use image node_id 5 for calling a global function with example usage: extract_entities_from_sentence(ner_sent) and returns: cleared_entities