code: def dataframe_to_xshards(
      data,
      validation_data,
      feature_cols,
      label_cols,
      mode="fit",
      num_workers=None,
      accept_str_col=False,
  ):
      from pyspark.sql import DataFrame
  
      valid_mode = {"fit", "evaluate", "predict"}
      assert mode in valid_mode, (
          f"invalid mode {mode} " f"mode should be one of {valid_mode}"
      )
      assert validation_data is None or isinstance(
          validation_data, DataFrame
      ), "validation data must be a spark DataFrame when data is a DataFrame"
      assert (
          feature_cols is not None
      ), "feature_col must be provided if data is a spark dataframe"
  
      if mode != "predict":
          assert (
              label_cols is not None
          ), "label_cols must be provided if data is a spark dataframe"
          # avoid empty partition for worker
          if data.rdd.getNumPartitions() < num_workers:
              data = data.repartition(num_workers)
          if validation_data is not None:
              num_data_part = data.rdd.getNumPartitions()
              validation_data = validation_data.repartition(
                  num_data_part
              )
  
      data = _dataframe_to_xshards(
          data, feature_cols, label_cols, accept_str_col
      )
      if validation_data is not None:
          validation_data = _dataframe_to_xshards(
              validation_data, feature_cols, label_cols, accept_str_col
          )
  
      return data, validation_data
  
file_path: analytics-zoo/pyzoo/zoo/orca/learn/utils.py
imports: from zoo.common.utils import get_file_list
  from zoo.orca.data import SparkXShards
  from zoo.orca.data.utils import get_size
  from zoo.util.utils import convert_row_to_numpy
  import numpy
label_desc: Use image node_id 10 for calling a global function with example usage: dataframe_to_xshards(data, validation_data, feature_cols, label_cols, mode, num_workers, accept_str_col) and returns: data,  validation_data