code: def convert_and_filter_topk(args):
      """Convert to lowercase, count word occurrences and save top-k words to a file"""
  
      counter = Counter()
      data_lower = os.path.join(args.output_dir, "lower.txt.gz")
  
      print(
          "\nConverting to lowercase and counting word occurrences ..."
      )
      with io.TextIOWrapper(
          io.BufferedWriter(gzip.open(data_lower, "w+")),
          encoding="utf-8",
      ) as file_out:
          # Open the input file either from input.txt or input.txt.gz
          _, file_extension = os.path.splitext(args.input_txt)
          if file_extension == ".gz":
              file_in = io.TextIOWrapper(
                  io.BufferedReader(gzip.open(args.input_txt)),
                  encoding="utf-8",
              )
          else:
              file_in = open(args.input_txt, encoding="utf-8")
  
          for line in progressbar.progressbar(file_in):
              line_lower = line.lower()
              counter.update(line_lower.split())
              file_out.write(line_lower)
  
          file_in.close()
  
      # Save top-k words
      print("\nSaving top {} words ...".format(args.top_k))
      top_counter = counter.most_common(args.top_k)
      vocab_str = "\n".join(word for word, count in top_counter)
      vocab_path = "vocab-{}.txt".format(args.top_k)
      vocab_path = os.path.join(args.output_dir, vocab_path)
      with open(vocab_path, "w+") as file:
          file.write(vocab_str)
  
      print("\nCalculating word statistics ...")
      total_words = sum(counter.values())
      print(
          "  Your text file has {} words in total".format(total_words)
      )
      print("  It has {} unique words".format(len(counter)))
      top_words_sum = sum(count for word, count in top_counter)
      word_fraction = (top_words_sum / total_words) * 100
      print(
          "  Your top-{} words are {:.4f} percent of all words".format(
              args.top_k, word_fraction
          )
      )
      print(
          '  Your most common word "{}" occurred {} times'.format(
              *top_counter[0]
          )
      )
      last_word, last_count = top_counter[-1]
      print(
          '  The least common word in your top-k is "{}" with {} times'.format(
              last_word, last_count
          )
      )
      for i, (w, c) in enumerate(reversed(top_counter)):
          if c > last_count:
              print(
                  '  The first word with {} occurrences is "{}" at place {}'.format(
                      c, w, len(top_counter) - 1 - i
                  )
              )
              break
  
      return data_lower, vocab_str
  
file_path: DeepSpeech/data/lm/generate_lm.py
imports: import argparse
  import gzip
  import io
  import os
  import subprocess
  from collections import Counter
  import progressbar
label_desc: Use image node_id 1 for calling a global function with example usage: convert_and_filter_topk(args) and returns: data_lower,  vocab_str