code: def process_thucnews(infold, outfold):
      modes = ["train", "test"]
      train_size = 0.8
      if not os.path.exists(infold):
          link = "thuctc.thunlp.org/"
          raise ValueError(
              f"Data not found at {infold}. "
              f"Please download THUCNews from {link}."
          )
  
      logging.info(
          f"Processing THUCNews dataset and store at {outfold}"
      )
      os.makedirs(outfold, exist_ok=True)
  
      outfiles = {}
      for mode in modes:
          outfiles[mode] = open(
              os.path.join(outfold, mode + ".tsv"),
              "a+",
              encoding="utf-8",
          )
      categories = [
          "体育",
          "娱乐",
          "家居",
          "彩票",
          "房产",
          "教育",
          "时尚",
          "时政",
          "星座",
          "游戏",
          "社会",
          "科技",
          "股票",
          "财经",
      ]
      for category in categories:
          label = categories.index(category)
          category_files = glob.glob(f"{infold}/{category}/*.txt")
          test_num = int(len(category_files) * (1 - train_size))
          test_files = category_files[:test_num]
          train_files = category_files[test_num:]
  
          for mode in modes:
              logging.info(
                  f"Processing {mode} data of the category {category}"
              )
              if mode == "test":
                  files = test_files
              else:
                  files = train_files
  
              if len(files) == 0:
                  logging.info(
                      f"Skipping category {category} for {mode} mode"
                  )
                  continue
  
              for file in tqdm.tqdm(files):
                  with open(file, "r", encoding="utf-8") as f:
                      news = f.read().strip().replace("\r", "")
                      news = news.replace("\n", "").replace("\t", " ")
                      outfiles[mode].write(f"{news}\t{label}\n")
      for mode in modes:
          outfiles[mode].close()
  
file_path: NeMo/examples/nlp/text_classification/data/import_datasets.py
imports: import argparse
  import csv
  import glob
  import os
  from os.path import exists
  import tqdm
  from nemo.utils import logging
label_desc: Use image node_id 4 for calling a global function with example usage: process_thucnews(infold, outfold) without return types