code: def read_infile(
      infile: Union[Path, str],
      *,
      from_words=False,
      word_column: int = WORD_COLUMN,
      pos_column: int = POS_COLUMN,
      tag_column: int = TAG_COLUMN,
      head_column: int = HEAD_COLUMN,
      dep_column: int = DEP_COLUMN,
      max_sents: int = -1,
      read_only_words: bool = False,
      read_syntax: bool = False,
  ) -> List[Tuple[List, Union[List, None]]]:
      """Reads input file in CONLL-U format
  
      Args:
          infile: a path to a file
          word_column: column containing words (default=1)
          pos_column: column containing part-of-speech labels (default=3)
          tag_column: column containing fine-grained tags (default=5)
          head_column: column containing syntactic head position (default=6)
          dep_column: column containing syntactic dependency label (default=7)
          max_sents: maximal number of sentences to read
          read_only_words: whether to read only words
          read_syntax: whether to return ``heads`` and ``deps`` alongside ``tags``. Ignored if read_only_words is ``True``
  
      Returns:
          a list of sentences. Each item contains a word sequence and an output sequence.
          The output sentence is ``None``, if ``read_only_words`` is ``True``,
          a single list of word tags if ``read_syntax`` is False,
          and a list of the form [``tags``, ``heads``, ``deps``] in case ``read_syntax`` is ``True``.
  
      """
      answer, curr_word_sent, curr_tag_sent = [], [], []
      curr_head_sent, curr_dep_sent = [], []
      # read_syntax = read_syntax and read_only_words
      if from_words:
          word_column, read_only_words = 0, True
      if infile is not sys.stdin:
          fin = open(infile, "r", encoding="utf8")
      else:
          fin = sys.stdin
      for line in fin:
          line = line.strip()
          if line.startswith("#"):
              continue
          if line == "":
              if len(curr_word_sent) > 0:
                  if read_only_words:
                      curr_tag_sent = None
                  elif read_syntax:
                      curr_tag_sent = [
                          curr_tag_sent,
                          curr_head_sent,
                          curr_dep_sent,
                      ]
                  answer.append((curr_word_sent, curr_tag_sent))
              curr_tag_sent, curr_word_sent = [], []
              curr_head_sent, curr_dep_sent = [], []
              if len(answer) == max_sents:
                  break
              continue
          splitted = line.split("\t")
          index = splitted[0]
          if not from_words and not index.isdigit():
              continue
          curr_word_sent.append(splitted[word_column])
          if not read_only_words:
              pos, tag = splitted[pos_column], splitted[tag_column]
              tag = pos if tag == "_" else "{},{}".format(pos, tag)
              curr_tag_sent.append(tag)
              if read_syntax:
                  curr_head_sent.append(int(splitted[head_column]))
                  curr_dep_sent.append(splitted[dep_column])
      if len(curr_word_sent) > 0:
          if read_only_words:
              curr_tag_sent = None
          elif read_syntax:
              curr_tag_sent = [
                  curr_tag_sent,
                  curr_head_sent,
                  curr_dep_sent,
              ]
          answer.append((curr_word_sent, curr_tag_sent))
      if infile is not sys.stdin:
          fin.close()
      return answer
  
file_path: DeepPavlov/deeppavlov/dataset_readers/morphotagging_dataset_reader.py
imports: import sys
  from logging import getLogger
  from pathlib import Path
  from typing import Dict, List, Union, Tuple, Optional
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.dataset_reader import DatasetReader
  from deeppavlov.core.data.utils import download_decompress, mark_done
label_desc: Use image node_id 2 for calling a global function with example usage: read_infile(infile) and returns: answer