code: def convert_row_to_numpy(
      row, schema, feature_cols, label_cols, accept_str_col=False
  ):
      def convert_for_cols(row, cols):
          import pyspark.sql.types as df_types
  
          result = []
          for name in cols:
              feature_type = schema[name].dataType
              if _is_scalar_type(feature_type, accept_str_col):
                  if isinstance(feature_type, df_types.FloatType):
                      result.append(
                          np.array(row[name]).astype(np.float32)
                      )
                  elif isinstance(feature_type, df_types.DoubleType):
                      result.append(
                          np.array(row[name]).astype(np.float64)
                      )
                  elif isinstance(feature_type, df_types.TimestampType):
                      result.append(
                          np.array(row[name]).astype("datetime64[ns]")
                      )
                  elif isinstance(feature_type, df_types.IntegerType):
                      result.append(
                          np.array(row[name]).astype(np.int32)
                      )
                  elif isinstance(feature_type, df_types.LongType):
                      result.append(
                          np.array(row[name]).astype(np.int64)
                      )
                  elif isinstance(feature_type, df_types.DecimalType):
                      result.append(
                          np.array(row[name]).astype(np.float64)
                      )
                  else:
                      result.append(np.array(row[name]))
              elif isinstance(feature_type, df_types.ArrayType):
                  if accept_str_col and isinstance(
                      feature_type.elementType, df_types.StringType
                  ):
                      result.append(np.array(row[name]).astype(str))
                  elif isinstance(
                      feature_type.elementType, df_types.FloatType
                  ):
                      result.append(
                          np.array(row[name]).astype(np.float32)
                      )
                  elif isinstance(
                      feature_type.elementType, df_types.DoubleType
                  ):
                      result.append(
                          np.array(row[name]).astype(np.float64)
                      )
                  elif isinstance(
                      feature_type.elementType, df_types.IntegerType
                  ):
                      result.append(
                          np.array(row[name]).astype(np.int32)
                      )
                  elif isinstance(
                      feature_type.elementType, df_types.LongType
                  ):
                      result.append(
                          np.array(row[name]).astype(np.int64)
                      )
                  elif isinstance(
                      feature_type.elementType, df_types.DecimalType
                  ):
                      result.append(
                          np.array(row[name]).astype(np.float64)
                      )
                  else:
                      result.append(np.array(row[name]))
              elif isinstance(feature_type, df_types.MapType):
                  keys = row[name].keys()
                  # TODO: Support more types with recursion
                  if isinstance(
                      feature_type.valueType, df_types.ArrayType
                  ):
                      if isinstance(
                          feature_type.valueType.elementType,
                          df_types.FloatType,
                      ):
                          result.append(
                              {
                                  k: np.array(row[name][k]).astype(
                                      np.float32
                                  )
                                  for k in keys
                              }
                          )
                  else:
                      invalidInputError(
                          False,
                          "unsupported MapType field {}, data {}".format(
                              schema[name], row[name]
                          ),
                      )
              elif isinstance(row[name], DenseVector):
                  result.append(row[name].values.astype(np.float32))
              else:
                  invalidInputError(
                      isinstance(row[name], SparseVector),
                      "unsupported field {}, data {}".format(
                          schema[name], row[name]
                      ),
                  )
                  result.append(row[name].toArray())
          if len(result) == 1:
              return result[0]
          return result
  
      features = convert_for_cols(row, feature_cols)
      if label_cols:
          labels = convert_for_cols(row, label_cols)
          return (features, labels)
      else:
          return (features,)
  
imports: import glob
  from bigdl.dllib.utils.file_utils import Sample
  import numpy
  from pyspark.ml.linalg import DenseVector, SparseVector, VectorUDT
  import sys
  import os
  import re
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 14 for calling a global function with example usage: convert_row_to_numpy(row, schema, feature_cols, label_cols, accept_str_col) and returns: result, features,  labels, features, result