docstr: Get model training results and new model.
docstr_tok: ["Get","model","training","results","and","new","model","."]
code: def step(
      self,
      data_creator,
      epochs=1,
      batch_size=32,
      verbose=1,
      callbacks=None,
      validation_data_creator=None,
      class_weight=None,
      initial_epoch=0,
      steps_per_epoch=None,
      validation_steps=None,
      validation_freq=1,
      data_config=None,
  ):
      """
      Get model training results and new model.
      """
      config = copy.copy(self.config)
      if data_config is not None:
          config.update(data_config)
      config["batch_size"] = batch_size
      val_data_creator = validation_data_creator
  
      history = self.distributed_train_func(
          data_creator,
          config,
          epochs=epochs,
          verbose=verbose,
          callbacks=callbacks,
          steps_per_epoch=steps_per_epoch,
          class_weight=class_weight,
          initial_epoch=initial_epoch,
          validation_data_creator=val_data_creator,
          validation_steps=validation_steps,
          validation_freq=validation_freq,
      )
      # history is a callbacks object
      # see https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/History
      # history.params is a dict with keys verbose, epochs and steps
      # history.history contains train and val stats for each epoch
      if history is None:
          stats = {}
      else:
          stats = dict()
          stats.update(history.params)
          stats.update(history.history)
  
      if self.model_dir is not None:
          model_state = {"weights": self.model.get_weights()}
          if self.rank == 0:
              # only chef save model to destination location
              save_pkl(
                  model_state, os.path.join(self.model_dir, "state.pkl")
              )
              save_model(
                  self.model, self._model_saved_path, save_format="h5"
              )
              self._stop_log_monitor()
          else:
              temp_dir = tempfile.mkdtemp()
              try:
                  save_model(
                      self.model, os.path.join(temp_dir, "model.h5")
                  )
              finally:
                  shutil.rmtree(temp_dir)
                  self._stop_log_monitor()
      else:
          if hasattr(self.model.optimizer, "get_weights"):
              model_state = {
                  "weights": self.model.get_weights(),
                  "opt_weights": self.model.optimizer.get_weights(),
              }
          else:
              model_state = {
                  "weights": self.model.get_weights(),
                  "opt_weights": [
                      v.numpy()
                      for v in self.model.optimizer.variables()
                  ],
              }
          self._stop_log_monitor()
      if self.rank == 0:
          if self.model_dir is not None:
              return [stats]
          else:
              return [stats, model_state]
      else:
          return []
  
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 6 for calling the SparkRunner obj's underlying member method code with example usage: obj.step(data_creator, epochs, batch_size, verbose, callbacks, validation_data_creator, class_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, data_config) and returns: list, list, list