code: def __convert_data(
      in_file: str, out_text_f: str, out_labels_f: str, max_length: int
  ):
      """
      Convert data from the IOB format to NeMo accepted format described below.
      in_file should be in the IOB format, see example here:
      https://www.clips.uantwerpen.be/conll2003/ner/.
  
      Args:
          in_file: input file name
          out_text_f: output file with text
          out_labels_f: output file with labels
          max_length: use -1 to leave the examples' length as is, otherwise long examples will be split into multiple
              examples
      After the conversion, the dataset is split into 2 files: text.txt
      and labels.txt.
      Each line of the text.txt file contains text sequences, where words
      are separated with spaces. The labels.txt file contains corresponding
      labels for each word in text.txt, the labels are separated with spaces.
      Each line of the files should follow the format:
      [WORD] [SPACE] [WORD] [SPACE] [WORD] (for text.txt) and
      [LABEL] [SPACE] [LABEL] [SPACE] [LABEL] (for labels.txt).
  
      """
      in_file = open(in_file, "r")
  
      if max_length == -1:
          with open(out_text_f, "w") as out_text, open(
              out_labels_f, "w"
          ) as out_labels:
              for line in in_file:
                  if line == "\n":
                      out_text.write(line)
                      out_labels.write(line)
                  else:
                      line = line.split()
                      out_text.write(line[0] + " ")
                      out_labels.write(line[-1] + " ")
  
      else:
          words = []
          labels = []
          with open(out_text_f, "w") as out_text, open(
              out_labels_f, "w"
          ) as out_labels:
              lines = in_file.readlines()
              for line_id, line in enumerate(lines):
                  logging.info(f"{line_id} {len(lines)}")
                  contends = line.strip()
                  if len(contends) == 0:
                      assert len(words) == len(labels)
                      if len(words) > max_length:
                          # split if the sentence is longer than max_length
                          while len(words) > max_length:
                              tmplabel = labels[:max_length]
                              for iidx in range(len(tmplabel)):
                                  if tmplabel.pop() == "O":
                                      break
                              l = " ".join(
                                  [
                                      label
                                      for label in labels[
                                          : len(tmplabel) + 1
                                      ]
                                      if len(label) > 0
                                  ]
                              )
                              w = " ".join(
                                  [
                                      word
                                      for word in words[
                                          : len(tmplabel) + 1
                                      ]
                                      if len(word) > 0
                                  ]
                              )
  
                              out_text.write(w + "\n")
                              out_labels.write(l + "\n")
                              words = words[len(tmplabel) + 1 :]
                              labels = labels[len(tmplabel) + 1 :]
  
                      if len(words) == 0:
                          continue
                      l = " ".join(
                          [label for label in labels if len(label) > 0]
                      )
                      w = " ".join(
                          [word for word in words if len(word) > 0]
                      )
  
                      out_text.write(w + "\n")
                      out_labels.write(l + "\n")
                      words = []
                      labels = []
                      continue
  
                  word = line.strip().split()[0]
                  label = line.strip().split()[-1]
                  words.append(word)
                  labels.append(label)
  
label_desc: Use image node_id 1 for calling a global function with example usage: __convert_data(in_file, out_text_f, out_labels_f, max_length) without return types