code: def convert_nkjp(nkjp_path, output_dir):
      """Converts NKJP NER data into IOB json format.
  
      nkjp_dir is the path to directory where NKJP files are located.
      """
      # Load XML NKJP
      print("Reading data from %s" % nkjp_path)
      if os.path.isfile(nkjp_path) and (
          nkjp_path.endswith(".tar.gz") or nkjp_path.endswith(".tgz")
      ):
          with tempfile.TemporaryDirectory() as nkjp_dir:
              print(
                  "Temporarily extracting %s to %s"
                  % (nkjp_path, nkjp_dir)
              )
              with tarfile.open(nkjp_path, "r:gz") as tar_in:
                  tar_in.extractall(nkjp_dir)
  
              subfolder_to_entities = load_xml_nkjp(nkjp_dir)
      elif os.path.isdir(nkjp_path):
          subfolder_to_entities = load_xml_nkjp(nkjp_path)
      else:
          raise FileNotFoundError(
              "Cannot find either unpacked dataset or gzipped file"
          )
      converted = []
      for subfolder_name, pars in subfolder_to_entities.items():
          for par_id, par in pars.items():
              paragraph_identifier = f"{subfolder_name}|{par_id}"
              par_tokens = []
              for _, sent in par.items():
                  tokens = sent.values()
                  srt = sorted(tokens, key=lambda tok: tok["i"])
                  for token in srt:
                      _ = token.pop("i")
                      _ = token.pop("seg_id")
                      par_tokens.append(token)
              par_tokens[0]["paragraph_id"] = paragraph_identifier
              converted.append(par_tokens)
  
      split = split_dataset(converted)
  
      for split_name, split in split.items():
          if split:
              with open(
                  os.path.join(
                      output_dir, f"pl_nkjp.{split_name}.json"
                  ),
                  "w",
                  encoding="utf-8",
              ) as f:
                  json.dump(split, f, ensure_ascii=False, indent=2)
  
imports: import argparse
  import json
  import os
  import random
  import tarfile
  import tempfile
  from tqdm import tqdm
label_desc: Use image node_id 13 for calling a global function with example usage: convert_nkjp(nkjp_path, output_dir) without return types