code: def read_examples_from_file(
      self, data_dir, mode: Union[Split, str]
  ) -> List[InputExample]:
      if isinstance(mode, Split):
          mode = mode.value
      file_path = os.path.join(data_dir, f"{mode}.txt")
      guid_index = 1
      examples = []
      with open(file_path, encoding="utf-8") as f:
          words = []
          labels = []
          for line in f:
              if (
                  line.startswith("-DOCSTART-")
                  or line == ""
                  or line == "\n"
              ):
                  if words:
                      examples.append(
                          InputExample(
                              guid=f"{mode}-{guid_index}",
                              words=words,
                              labels=labels,
                          )
                      )
                      guid_index += 1
                      words = []
                      labels = []
              else:
                  splits = line.split(" ")
                  words.append(splits[0])
                  if len(splits) > 1:
                      labels.append(
                          splits[self.label_idx].replace("\n", "")
                      )
                  else:
                      # Examples could have no label for mode = "test"
                      labels.append("O")
          if words:
              examples.append(
                  InputExample(
                      guid=f"{mode}-{guid_index}",
                      words=words,
                      labels=labels,
                  )
              )
      return examples
  
file_path: transformers/examples/legacy/token-classification/tasks.py
imports: import logging
  import os
  from typing import List, TextIO, Union
  from conllu import parse_incr
  from utils_ner import InputExample, Split, TokenClassificationTask
label_desc: Use image node_id 2 for calling the NER obj's underlying member method code with example usage: obj.read_examples_from_file(data_dir, mode) and returns: examples