code: def read_data_file(fp: str, upsample_file: bool = False):
      """Reading the raw data from a file of NeMo format
      For more info about the data format, refer to the
      `text_normalization doc <https://github.com/NVIDIA/NeMo/blob/main/docs/source/nlp/text_normalization.rst>`.
  
      Args:
          fp: file paths
          upsample_file: whether or not this input file should be used in full or only for upsampling, i.e. only as a subset
      Returns:
          insts: List of sentences parsed as list of words
      """
  
      insts, w_words, s_words, classes = [], [], [], []
      with open(fp, "r", encoding="utf-8") as f:
          sentence_patterns = {
              "FRACTION": defaultdict(int),
              "MEASURE": defaultdict(int),
              "TIME": defaultdict(int),
              "MONEY": defaultdict(int),
          }
          for line in f:
              es = [e.strip() for e in line.strip().split("\t")]
              if es[0] == "<eos>":
                  if not upsample_file:
                      inst = (classes, w_words, s_words)
                      insts.append(inst)
                  else:
                      ok = include_sentence(sentence_patterns)
                      if ok:
                          inst = (classes, w_words, s_words)
                          insts.append(inst)
                  # Reset
                  w_words, s_words, classes = [], [], []
                  sentence_patterns = {
                      "FRACTION": defaultdict(int),
                      "MEASURE": defaultdict(int),
                      "TIME": defaultdict(int),
                      "MONEY": defaultdict(int),
                  }
  
              else:
                  classes.append(es[0])
                  w_words.append(es[1])
                  s_words.append(es[2])
                  if not upsample_file:
                      register_patterns(
                          cls=es[0], input_str=es[1], pretty=args.pretty
                      )
                  else:
                      if es[0] in classes_to_upsample:
                          patterns = lookup_patterns(
                              cls=es[0], input_str=es[1]
                          )
                          update_patterns(
                              sentence_patterns[es[0]], patterns
                          )
          if not upsample_file:
              inst = (classes, w_words, s_words)
              insts.append(inst)
      return insts
  
file_path: NeMo/examples/nlp/duplex_text_normalization/data/en/upsample.py
imports: import glob
  from argparse import ArgumentParser
  from collections import defaultdict
  from typing import List
  import numpy
  import regex
label_desc: Use image node_id 2 for calling a global function with example usage: read_data_file(fp, upsample_file) and returns: insts