docstr: Sets up TensorFLow distributed environment, initializes the model,
  runs a training epoch and updates the model parameters
docstr_tok: ["Sets","up","TensorFLow","distributed","environment",",","initializes","the","model",",","runs","a","training","epoch","and","updates","the","model","parameters"]
code: def distributed_train_func(
      self,
      data_creator,
      config,
      epochs=1,
      verbose=1,
      callbacks=None,
      initial_epoch=0,
      validation_data_creator=None,
      class_weight=None,
      steps_per_epoch=None,
      validation_steps=None,
      validation_freq=1,
  ):
      """
      Sets up TensorFLow distributed environment, initializes the model,
      runs a training epoch and updates the model parameters
      """
      with self.strategy.scope():
          dataset_handler = DatasetHandler.get_handler(
              self.backend, self.rank, self.size
          )
          (
              train_dataset,
              test_dataset,
          ) = dataset_handler.handle_datasets_train(
              data_creator=data_creator,
              validation_data_creator=validation_data_creator,
              config=config,
              epochs=epochs,
              steps_per_epoch=steps_per_epoch,
              validation_steps=validation_steps,
          )
      if callbacks:
          replace_specific_object_from_callbacks(
              callbacks,
              tf.keras.callbacks.ModelCheckpoint,
              ModelCheckpoint,
              self.rank,
          )
  
          replaced_log_dir = process_tensorboard_in_callbacks(
              callbacks, "fit", self.rank
          )
  
      history = self.model.fit(
          train_dataset,
          epochs=epochs,
          verbose=verbose,
          callbacks=callbacks,
          validation_data=test_dataset,
          class_weight=class_weight,
          initial_epoch=initial_epoch,
          steps_per_epoch=steps_per_epoch,
          validation_steps=validation_steps,
          validation_freq=validation_freq,
      )
  
      if callbacks:
          if replaced_log_dir and os.path.exists(replaced_log_dir):
              shutil.rmtree(replaced_log_dir)
  
      return history
  
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 5 for calling the SparkRunner obj's underlying member method code with example usage: obj.distributed_train_func(data_creator, config, epochs, verbose, callbacks, initial_epoch, validation_data_creator, class_weight, steps_per_epoch, validation_steps, validation_freq) and returns: history