code: def to_tensor_slice_dataset(data, label, config):
      # TODO: make OrderedDict more general
      features = collections.OrderedDict()
      output_types = collections.OrderedDict()
      for i in range(len(CONTINUOUS_COLUMNS)):
          import numpy as np
  
          features[CONTINUOUS_COLUMNS[i]] = data[i].astype(np.float32)
          output_types[CONTINUOUS_COLUMNS[i]] = tf.float32
      for j in range(len(CATEGORICAL_COLUMNS)):
          # EmbeddingVariable only supports int64 not int32.
          features[CATEGORICAL_COLUMNS[j]] = data[
              j + len(CONTINUOUS_COLUMNS)
          ].astype("int64")
          output_types[CATEGORICAL_COLUMNS[j]] = tf.int64
          labels = label
  
      def get_item():
          i = 0
          size = len(labels)
          while i < size:
              single_features = collections.OrderedDict()
              for k, v in features.items():
                  single_features[k] = v[i]
              single_label = labels[i]
              yield single_features, single_label
              i += 1
  
      # dataset = tf.data.Dataset.from_generator(get_item, output_types=(output_types, tf.int32))
  
      dataset = tf.data.Dataset.from_tensor_slices((features, labels))
      dataset = dataset.shuffle(
          buffer_size=20000, seed=config["seed"]
      )  # fix seed for reproducing
      dataset = dataset.repeat(config["no_of_epochs"])
      dataset = dataset.prefetch(config["batch_size"])
      dataset = dataset.batch(config["batch_size"])
      dataset = dataset.prefetch(2)
      return dataset
  
imports: import time
  import argparse
  import tensorflow
  import os
  import sys
  import math
  import collections
  from tensorflow.python.client import timeline
  import json
  from tensorflow.python.ops import partitioned_variables
  import ray
  from bigdl.dllib.utils.log4Error import *
  from bigdl.orca import init_orca_context, stop_orca_context, OrcaContext
  from bigdl.orca.data.utils import process_spark_xshards
  from bigdl.orca.learn.utils import maybe_dataframe_to_xshards
  from bigdl.friesian.feature import FeatureTable
label_desc: Use image node_id 9 for calling a global function with example usage: to_tensor_slice_dataset(data, label, config) and returns: dataset