code: def dataframe_to_xshards_of_pandas_df(
      data, feature_cols, label_cols=None, accept_str_col=False
  ):
      """
      This function transform a spark dataframe to xshards of pandas dataframe.
      :param data: a spark dataframe
      :param feature_cols: the col names you would like to select and transform to pandas
      :param label_cols: the target col name you would like to select and transform to pandas
             typically, you may leave this to None since there is no difference to use
             feature_cols directly.
      :param accept_str_col: bool, states if allow str to be a valid type.
  
      :return: a sparkxshards of pandas dataframe with feature_cols+label_cols as header.
      """
      from bigdl.orca import OrcaContext
  
      schema = data.schema
      shard_size = OrcaContext._shard_size
      numpy_rdd = data.rdd.map(
          lambda row: convert_row_to_numpy(
              row, schema, feature_cols, label_cols, accept_str_col
          )
      )
      shard_rdd = numpy_rdd.mapPartitions(
          lambda x: arrays2pandas(
              x, feature_cols, label_cols, shard_size
          )
      )
      return SparkXShards(shard_rdd)
  
imports: from contextlib import closing
  import socket
  import sys
  import tempfile
  import shutil
  from bigdl.dllib.utils import log4Error
  from bigdl.dllib.utils.common import callBigDlFunc
  from bigdl.dllib.utils.file_utils import get_file_list, is_local_path
  from bigdl.orca.data import SparkXShards
  from bigdl.orca.data.utils import get_size
  from bigdl.orca.data.file import put_local_dir_tree_to_remote, put_local_file_to_remote, get_remote_file_to_local, get_remote_dir_to_local
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from functools import partial
  import numpy
  from bigdl.orca.common import SafePickle
  import os
  import subprocess
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 19 for calling a global function with example usage: dataframe_to_xshards_of_pandas_df(data, feature_cols, label_cols, accept_str_col) and returns: SparkXShards