code: def handle_datasets_train(
      self,
      data_creator,
      validation_data_creator,
      config,
      epochs,
      steps_per_epoch,
      validation_steps,
  ):
      config, local_batch_size = self._handle_batch_size(config)
      config["rank"] = self.rank
      config["size"] = self.size
      # Use global batch size here for data_creator since TensorFlow
      # will shard the dataset.
      # batch_size won't be used in data_creator for SparkXShards.
      train_dataset = data_creator(config, config["batch_size"])
      if isinstance(train_dataset, list) and all(
          [isinstance(x, dict) for x in train_dataset]
      ):
          invalidInputError(
              steps_per_epoch is not None,
              "steps_per_epoch must be provided for xshard",
          )
          train_dataset = self._handle_xshards(
              train_dataset,
              steps=steps_per_epoch * epochs,
              local_batch_size=local_batch_size,
              shuffle=True,
          )
      else:
          train_dataset = self._handle_sharding(train_dataset)
  
      if validation_data_creator is not None:
          test_dataset = validation_data_creator(
              config, config["batch_size"]
          )
          if isinstance(test_dataset, list) and all(
              [isinstance(x, dict) for x in test_dataset]
          ):
              invalidInputError(
                  validation_steps is not None,
                  "validation_steps must be provided"
                  " when use xshards for evaluate",
              )
              test_dataset = self._handle_xshards(
                  test_dataset,
                  steps=validation_steps,
                  local_batch_size=local_batch_size,
                  shuffle=False,
              )
          else:
              test_dataset = self._handle_sharding(test_dataset)
      else:
          test_dataset = None
  
      return train_dataset, test_dataset
  
imports: import json
  import os
  import tempfile
  import shutil
  import copy
  import tensorflow
  from bigdl.orca.data.utils import partition_get_data_label
  from bigdl.orca.data.file import exists
  from bigdl.orca.learn.utils import save_pkl, duplicate_stdout_stderr_to_file, get_rank, process_tensorboard_in_callbacks, save_model, load_model, replace_specific_object_from_callbacks
  from bigdl.orca.learn.log_monitor import LogMonitor
  from bigdl.orca.learn.tf2.callbacks import ModelCheckpoint
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 2 for calling the DatasetHandler obj's underlying member method code with example usage: obj.handle_datasets_train(data_creator, validation_data_creator, config, epochs, steps_per_epoch, validation_steps) and returns: train_dataset,  test_dataset