class_docstr: A mixedin class for nano keras Sequential and Model, adding more functions.
docstr: Override tf.keras.Model.fit to add more parameters.
  
  All arguments that already exists in tf.keras.Model.fit has the same sementics with
  tf.keras.Model.fit.
  
  Additional parameters:
  
  :param num_processes: when num_processes is not None, it specifies how many sub-processes
                 to launch to run pseudo-distributed training; when num_processes is None,
                 training will run in the current process.
  :param backend: when num_processes is not None, it specifies which backend to use when
                 launching sub-processes to run psedu-distributed training; when
                 num_processes is None, this parameter takes no effect.
code: def fit(
      self,
      x=None,
      y=None,
      batch_size=None,
      epochs=1,
      verbose="auto",
      callbacks=None,
      validation_split=0.0,
      validation_data=None,
      shuffle=True,
      class_weight=None,
      sample_weight=None,
      initial_epoch=0,
      steps_per_epoch=None,
      validation_steps=None,
      validation_batch_size=None,
      validation_freq=1,
      max_queue_size=10,
      workers=1,
      use_multiprocessing=False,
      num_processes=None,
      backend="multiprocessing",
  ):
      """
      Override tf.keras.Model.fit to add more parameters.
  
      All arguments that already exists in tf.keras.Model.fit has the same sementics with
      tf.keras.Model.fit.
  
      Additional parameters:
  
      :param num_processes: when num_processes is not None, it specifies how many sub-processes
                     to launch to run pseudo-distributed training; when num_processes is None,
                     training will run in the current process.
      :param backend: when num_processes is not None, it specifies which backend to use when
                     launching sub-processes to run psedu-distributed training; when
                     num_processes is None, this parameter takes no effect.
      """
      fit_kwargs = dict(
          x=x,
          y=y,
          batch_size=batch_size,
          epochs=epochs,
          verbose=verbose,
          callbacks=callbacks,
          validation_split=validation_split,
          validation_data=validation_data,
          shuffle=shuffle,
          class_weight=class_weight,
          sample_weight=sample_weight,
          initial_epoch=initial_epoch,
          steps_per_epoch=steps_per_epoch,
          validation_steps=validation_steps,
          validation_batch_size=validation_batch_size,
          validation_freq=validation_freq,
          max_queue_size=max_queue_size,
          workers=workers,
          use_multiprocessing=use_multiprocessing,
      )
  
      # adapt the different default param values of training_v1.Model and training.Model
      if isinstance(self, V1Model):
          if validation_batch_size is None:
              fit_kwargs.pop("validation_batch_size")
          if verbose == "auto":
              fit_kwargs["verbose"] = 1
  
      if num_processes is not None:
          if validation_data is not None:
              msg = "validataion_data must be a tf.data.Dataset for multi-process training"
              invalidInputError(
                  isinstance(
                      x, (tf.compat.v1.data.Dataset, tf.data.Dataset)
                  ),
                  msg,
              )
          msg = "x must be a tf.data.Dataset for multi-process training"
          invalidInputError(
              isinstance(
                  x, (tf.compat.v1.data.Dataset, tf.data.Dataset)
              ),
              msg,
          )
  
          if backend == "horovod":
              _backend = create_horovod_multiprocessing_backend()
              history = distributed_train_keras_horovod(
                  _backend,
                  model=self,
                  nprocs=num_processes,
                  fit_kwargs=fit_kwargs,
              )
              return history
  
          else:
              if backend == "multiprocessing":
                  from bigdl.nano.utils.tf import MultiprocessingBackend
  
                  _backend = MultiprocessingBackend()
              elif backend == "ray":
                  _backend = create_ray_multiprocessing_backend()
              else:
                  invalidInputError(
                      False,
                      "Backend {} is not implemented.".format(backend),
                  )
              from bigdl.nano.tf.keras.distributed_utils import (
                  distributed_train_keras,
              )
  
              history = distributed_train_keras(
                  _backend,
                  model=self,
                  nprocs=num_processes,
                  fit_kwargs=fit_kwargs,
              )
              return history
      else:
          return self.fit_old(**fit_kwargs)
  
file_path: BigDL/python/nano/src/bigdl/nano/tf/keras/training_utils.py
imports: import tensorflow
  from bigdl.nano.deps.ray.ray_api import create_ray_multiprocessing_backend
  from bigdl.nano.deps.horovod.horovod_api import create_horovod_multiprocessing_backend
  from bigdl.nano.deps.horovod.horovod_api import distributed_train_keras_horovod
  from bigdl.nano.utils.common import invalidInputError
  from keras.engine.training import Model
  from keras.engine.training_v1 import Model
label_desc: Use image node_id 1 for calling the TrainingUtils obj's underlying member method code with example usage: obj.fit(x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing, num_processes, backend) and returns: self, history, history