code: def process_chemprot(
      source_dir, target_dir, uncased, modes=["train", "test", "dev"]
  ):
      if not os.path.exists(source_dir):
          link = "https://github.com/arwhirang/recursive_chemprot/tree/master/Demo/tree_LSTM/data"
          raise ValueError(
              f"Data not found at {source_dir}. "
              f"Please download ChemProt from {link}."
          )
  
      logging.info(
          f"Processing Chemprot dataset and store at {target_dir}"
      )
      os.makedirs(target_dir, exist_ok=True)
  
      naming_map = {
          "train": "trainingPosit_chem",
          "test": "testPosit_chem",
          "dev": "developPosit_chem",
      }
  
      def _read_tsv(input_file, quotechar=None):
          """Reads a tab separated value file."""
          with open(input_file, "r") as f:
              reader = csv.reader(
                  f, delimiter="\t", quotechar=quotechar
              )
              lines = []
              for line in reader:
                  lines.append(line)
              return lines
  
      outfiles = {}
      label_mapping = {}
      out_label_mapping = open(
          os.path.join(target_dir, "label_mapping.tsv"), "w"
      )
      for mode in modes:
          outfiles[mode] = open(
              os.path.join(target_dir, mode + ".tsv"), "w"
          )
          input_file = os.path.join(source_dir, naming_map[mode])
          lines = _read_tsv(input_file)
          for line in lines:
              text = line[1]
              label = line[2]
              if label == "True":
                  label = line[3]
              if uncased:
                  text = text.lower()
              if label not in label_mapping:
                  out_label_mapping.write(
                      f"{label}\t{len(label_mapping)}\n"
                  )
                  label_mapping[label] = len(label_mapping)
              label = label_mapping[label]
              outfiles[mode].write(f"{text}\t{label}\n")
      for mode in modes:
          outfiles[mode].close()
      out_label_mapping.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 3 for calling a global function with example usage: process_chemprot(source_dir, target_dir, uncased, modes) and returns: lines