code: def partitions_get_tf_dataset(partition_list, has_label=True):
      import tensorflow as tf  # type:ignore
  
      partition_data = [
          item for partition in partition_list for item in partition
      ]
      if len(partition_data) != 0:
          sample = partition_data[0]
          keys = sample.keys()
          if "x" in keys:
              if has_label:
                  invalidInputError(
                      "y" in keys,
                      "key y should in each shard if has_label=True",
                  )
              data, label = partition_get_data_label(
                  partition_data, allow_tuple=True, allow_list=False
              )
              dataset = tf.data.Dataset.from_tensor_slices(
                  (data, label)
              )
          elif "ds_def" in keys and "elem_spec" in keys:
              from tensorflow.python.distribute.coordinator.values import (
                  deserialize_dataset_from_graph,
              )  # type:ignore
              from functools import reduce
  
              dataset_list = [
                  deserialize_dataset_from_graph(
                      serialized_dataset["ds_def"],
                      serialized_dataset["elem_spec"],
                  )
                  for serialized_dataset in partition_data
              ]
              dataset = reduce(
                  lambda x, y: x.concatenate(y), dataset_list
              )
          else:
              invalidInputError(
                  False,
                  "value of x and y should be a ndarray, "
                  "a tuple of ndarrays or a list of ndarrays",
              )
      else:
          # TODO: may cause error
          dataset = tf.data.Dataset.from_tensor_slices(([], []))
  
      return dataset
  
imports: from bigdl.dllib.utils.file_utils import get_file_list, callZooFunc
  from bigdl.dllib.utils.utils import convert_row_to_numpy
  from bigdl.dllib.utils.common import *
  from bigdl.dllib.utils.log4Error import *
  import pyspark.sql.functions
  from typing import TYPE_CHECKING, Dict, List, Optional, Type, Union
  from numpy import float32, int32
label_desc: Use image node_id 9 for calling a global function with example usage: partitions_get_tf_dataset(partition_list, has_label) and returns: dataset