code: def generate_reference_text_file_for_conll(
      conll_input_filepath, conll_output_filepath, text_folder
  ):
      """
      generates reference text files and adds the corresponding filename and token offsets to conll file.
  
      conll_input_filepath: path to a conll-formatted file without filename and token offsets
      text_folder: folder to write the reference text file to
      """
      dataset_type = utils.get_basename_without_extension(
          conll_input_filepath
      )
      conll_file = codecs.open(conll_input_filepath, "r", "UTF-8")
      utils.create_folder_if_not_exists(text_folder)
      text = ""
      new_conll_string = ""
      character_index = 0
      document_count = 0
      text_base_filename = "{0}_text_{1}".format(
          dataset_type, str(document_count).zfill(5)
      )
      for line in conll_file:
          split_line = line.strip().split(" ")
          # New document
          if "-DOCSTART-" in split_line[0]:
              new_conll_string += line
              if len(text) != 0:
                  with codecs.open(
                      os.path.join(
                          text_folder,
                          "{0}.txt".format(text_base_filename),
                      ),
                      "w",
                      "UTF-8",
                  ) as f:
                      f.write(text)
              text = ""
              character_index = 0
              document_count += 1
              text_base_filename = "{0}_text_{1}".format(
                  dataset_type, str(document_count).zfill(5)
              )
              continue
          # New sentence
          elif len(split_line) == 0 or len(split_line[0]) == 0:
              new_conll_string += "\n"
              if text != "":
                  text += "\n"
                  character_index += 1
              continue
          token = split_line[0]
          start = character_index
          end = start + len(token)
          text += token + " "
          character_index += len(token) + 1
          new_conll_string += (
              " ".join(
                  [token, text_base_filename, str(start), str(end)]
                  + split_line[1:]
              )
              + "\n"
          )
      if len(text) != 0:
          with codecs.open(
              os.path.join(
                  text_folder, "{0}.txt".format(text_base_filename)
              ),
              "w",
              "UTF-8",
          ) as f:
              f.write(text)
      conll_file.close()
  
      with codecs.open(conll_output_filepath, "w", "UTF-8") as f:
          f.write(new_conll_string)
  
file_path: NeuroNER/neuroner/conll_to_brat.py
imports: import codecs
  import glob
  import os
  import shutil
  from neuroner import utils
  from neuroner import utils_nlp
label_desc: Use image node_id 1 for calling a global function with example usage: generate_reference_text_file_for_conll(conll_input_filepath, conll_output_filepath, text_folder) without return types