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):
                  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(np.str))
                  else:
                      result.append(
                          np.array(row[name]).astype(np.float32)
                      )
              elif isinstance(row[name], DenseVector):
                  result.append(row[name].values.astype(np.float32))
              else:
                  assert 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,)
  
file_path: analytics-zoo/pyzoo/zoo/util/utils.py
imports: import glob
  from zoo.common import Sample
  import numpy
  from pyspark.ml.linalg import DenseVector, SparseVector, VectorUDT
label_desc: Use image node_id 12 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