code: def preprocess_and_save(data_tbl, models, mode, save_path):
      data_tbl = (
          data_tbl.encode_string(CAT_COLS, models)
          .fillna(0, INT_COLS + CAT_COLS)
          .log(INT_COLS)
      )
      data_tbl = data_tbl.ordinal_shuffle_partition()
      if save_path:
          if mode == "train":
              save_path = os.path.join(save_path, "saved_data")
          elif mode == "test":
              save_path = os.path.join(save_path, "saved_data_test")
          else:
              invalidInputError(
                  False, "mode should be either train or test"
              )
          print("Saving {} data files to {}".format(mode, save_path))
          data_tbl.write_parquet(save_path)
      else:
          data_tbl.compute()
      return data_tbl
  
imports: import os
  from time import time
  from argparse import ArgumentParser
  from bigdl.orca import init_orca_context, stop_orca_context
  from bigdl.friesian.feature import FeatureTable
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 2 for calling a global function with example usage: preprocess_and_save(data_tbl, models, mode, save_path) and returns: data_tbl