code: def string_index(df, col):
      indexer = StringIndexer(
          inputCol=col, outputCol=col + "_index"
      ).fit(df)
      df = indexer.transform(df)
      df = df.drop(col).withColumnRenamed(col + "_index", col)
      # The StringIndexer output is float type.
      # Change to 1-based index with 0 reversed for unknown features.
      df = df.withColumn(col, df[col].cast("long") + 1)
      embed_dim = df.agg({col: "max"}).collect()[0][f"max({col})"] + 1
      return df, embed_dim
  
file_path: BigDL/python/orca/tutorial/NCF/process_spark_dataframe.py
imports: import os
  from pyspark.ml.feature import StringIndexer, MinMaxScaler, VectorAssembler
  from pyspark.ml import Pipeline
  from pyspark.sql.types import StructField, StructType, IntegerType, LongType, ArrayType, StringType
  from pyspark.sql.functions import udf, lit, collect_list, explode, concat
  from bigdl.orca import OrcaContext
label_desc: Use image node_id 3 for calling a global function with example usage: string_index(df, col) and returns: df,  embed_dim