code: def xshard_to_sample(data):
      from bigdl.dllib.utils.file_utils import Sample
  
      data = check_type_and_convert(
          data, allow_list=True, allow_tuple=False
      )
      features = data["x"]
      length = features[0].shape[0]
      if "y" in data:
          labels = data["y"]
      else:
          labels = np.array([[-1] * length])
  
      for i in range(length):
          fs = [feat[i] for feat in features]
          ls = [l[i] for l in labels]
          if len(fs) == 1:
              fs = fs[0]
          if len(ls) == 1:
              ls = ls[0]
          yield Sample.from_ndarray(fs, ls)
  
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 10 for calling a global function with example usage: xshard_to_sample(data) without return types