code: def partition_refs_to_creator(partition_refs):
      def data_creator(config, batch_size):
          from bigdl.orca.data.utils import (
              partitions_get_data_label,
              index_data,
              get_size,
          )
          from torch.utils.data import Dataset, DataLoader
  
          class NDArrayDataset(Dataset):
              def __init__(self, x, y):
                  self.x = x  # features
                  self.y = y  # labels
  
              def __len__(self):
                  return get_size(self.y)
  
              def __getitem__(self, i):
                  index_data_x = index_data(self.x, i)
                  if isinstance(index_data_x, (list, tuple)):
                      return (*index_data_x, index_data(self.y, i))
                  else:
                      return (index_data_x, index_data(self.y, i))
  
          params = {"batch_size": batch_size, "shuffle": True}
          for arg in [
              "shuffle",
              "sampler",
              "batch_sampler",
              "num_workers",
              "collate_fn",
              "pin_memory",
              "drop_last",
              "timeout",
              "worker_init_fn",
              "multiprocessing_context",
          ]:
              if arg in config:
                  params[arg] = config[arg]
          data, label = partitions_get_data_label(
              ray.get(partition_refs),
              allow_tuple=False,
              allow_list=False,
          )
          print("Data size on worker: ", len(label))
          dataset = NDArrayDataset(data, label)
          data_loader = DataLoader(dataset, **params)
          return data_loader
  
      return data_creator
  
imports: import types
  import copy
  import logging
  import math
  from bigdl.orca.data.ray_xshards import RayXShards
  from bigdl.orca.learn.pytorch.pytorch_ray_worker import PytorchRayWorker
  from bigdl.orca.learn.utils import maybe_dataframe_to_xshards, dataframe_to_xshards, convert_predict_xshards_to_dataframe, update_predict_xshards, process_xshards_of_pandas_dataframe, add_predict_to_pd_xshards
  from bigdl.orca.ray import OrcaRayContext
  from bigdl.orca.learn.pytorch.core.base_ray_estimator import BaseRayEstimator
  from bigdl.orca.learn.pytorch.utils import process_stats, check_for_failure
  from bigdl.orca.learn.pytorch.callbacks.maincallback import make_only_mainCallback
  from bigdl.orca.learn.pytorch.callbacks.tqdm import TqdmCallback, is_tqdm_exists
  from bigdl.orca.learn.pytorch.callbacks.maxsteps import MaxstepsCallback
  import ray
  from bigdl.dllib.utils.log4Error import invalidInputError
  from typing import TYPE_CHECKING, Union, Optional, Callable, Dict, List
label_desc: Use image node_id 1 for calling a global function with example usage: partition_refs_to_creator(partition_refs) and returns: data_creator, data_loader, get_size, unknown,  index_data, index_data_x,  index_data