code: def spark_df_to_ray_dataset(df: "SparkDataFrame") -> "Dataset":
      """
      Convert a Spark DataFrame to Ray Dataset. The block number of ray datasets equals to the
      partition number of the input DataFrame.
      :param df: A Spark dataframe.
      :return: A Ray Dataset holding Arrow records read from the dataframe.
      """
      spark_xshards = spark_df_to_pd_sparkxshards(df)
      ray_dataset = spark_xshards_to_ray_dataset(spark_xshards)
      return ray_dataset
  
imports: from py4j.protocol import Py4JError
  from bigdl.orca.data.utils import *
  from bigdl.orca import OrcaContext
  from bigdl.dllib.utils.common import get_node_and_core_number, get_spark_sql_context, get_spark_context
  from bigdl.dllib.utils import nest
  from bigdl.dllib.utils.log4Error import invalidInputError
  import numpy
  from typing import TYPE_CHECKING, Any
  from typing import Callable, Dict, List, Optional, Tuple, Union
label_desc: Use image node_id 1 for calling a global function with example usage: spark_df_to_ray_dataset(df) and returns: ray_dataset