code: def read_single_file(input_file, bio_format=True):
      """
      Reads an IJC NER file and returns a list of list of lines
      """
      sentences = []
      lineno = 0
      with open(input_file) as fin:
          current_sentence = []
          in_ner = False
          in_sentence = False
          printed_first = False
          nesting = 0
          for line in fin:
              lineno = lineno + 1
              line = line.strip()
              if not line:
                  continue
              if line.startswith("<Story") or line.startswith(
                  "</Story>"
              ):
                  assert not current_sentence, (
                      "File %s had an unexpected <Story> tag"
                      % input_file
                  )
                  continue
  
              if line.startswith("<Sentence"):
                  assert not current_sentence, (
                      "File %s has a nested sentence" % input_file
                  )
                  continue
  
              if line.startswith("</Sentence>"):
                  # Would like to assert that empty sentences don't exist, but alas, they do
                  # assert current_sentence, "File %s has an empty sentence at %d" % (input_file, lineno)
                  # AssertionError: File .../hi_ijc/training-hindi/193.naval.utf8 has an empty sentence at 74
                  if current_sentence:
                      sentences.append(current_sentence)
                  current_sentence = []
                  continue
  
              if line == "))":
                  assert in_sentence, (
                      "File %s closed a sentence when there was no open sentence at %d"
                      % (input_file, lineno)
                  )
                  nesting = nesting - 1
                  if nesting < 0:
                      in_sentence = False
                      nesting = 0
                  elif nesting == 0:
                      in_ner = False
                  continue
  
              pieces = line.split("\t")
              if pieces[0] == "0":
                  assert (
                      pieces[1] == "(("
                  ), "File %s has an unexpected first line at %d" % (
                      input_file,
                      lineno,
                  )
                  in_sentence = True
                  continue
  
              if pieces[1] == "((":
                  nesting = nesting + 1
                  if nesting == 1:
                      if len(pieces) < 4:
                          tag = None
                      else:
                          assert (
                              pieces[3][0] == "<"
                              and pieces[3][-1] == ">"
                          ), (
                              "File %s has an unexpected tag format at %d: %s"
                              % (input_file, lineno, pieces[3])
                          )
                          ne, tag = pieces[3][1:-1].split("=", 1)
                          assert pieces[3] == "<%s=%s>" % (ne, tag), (
                              "File %s has an unexpected tag format at %d: %s"
                              % (input_file, lineno, pieces[3])
                          )
                          in_ner = True
                          printed_first = False
                          tag = convert_tag(tag)
              elif in_ner and tag:
                  if bio_format:
                      if printed_first:
                          current_sentence.append(
                              (pieces[1], "I-" + tag)
                          )
                      else:
                          current_sentence.append(
                              (pieces[1], "B-" + tag)
                          )
                          printed_first = True
                  else:
                      current_sentence.append((pieces[1], tag))
              else:
                  current_sentence.append((pieces[1], "O"))
      assert not current_sentence, "File %s is unclosed!" % input_file
      return sentences
  
imports: import argparse
  import random
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: read_single_file(input_file, bio_format) and returns: sentences