class_docstr: asr keras base solver
class_docstr_tok: ["asr","keras","base","solver"]
docstr: build model like tf.estimator.Estimator
docstr_tok: ["build","model","like","tf.estimator.Estimator"]
code: def model_fn(self, mode):
      """build model like tf.estimator.Estimator"""
      with tf.device("/cpu:0"):
          self._model = super().model_fn()
  
      if not self.model.built:
          assert self.batch_input_shape
          # data must be (features, labels), only using features as input
          self.model.build(input_shape=self.batch_input_shape[0])
  
      assert self._init_epoch in range(0, self._num_epochs)
      model_load_type, model_file_name = solver_utils.get_model_file(
          dir_name=self._model_path,
          file_name_pattern=self._checkpoint_file_pattern,
          mode=mode,
          model_load_type=self._model_load_type,
          specified_model_file_name=self._specified_model_file,
      )
  
      logging.info(
          "{}-{}: load model from {}".format(
              mode, model_load_type, model_file_name
          )
      )
      if model_file_name is not None:
          if self.model.built:
              self.model.load_weights(
                  str(model_file_name), by_name=False
              )
          else:
              self._model = tf.keras.models.load_model(
                  str(model_file_name)
              )
  
      # parallel and compile model
      self.build(multi_gpu=(mode == utils.TRAIN))
  
imports: from pathlib import Path
  from absl import logging
  import delta.compat
  from tensorflow.keras.utils import multi_gpu_model
  from tensorflow.keras.callbacks import EarlyStopping
  from tensorflow.keras.callbacks import TensorBoard
  from tensorflow.keras.callbacks import CSVLogger
  from tensorflow.keras.callbacks import ReduceLROnPlateau
  from delta import utils
  from delta.utils.solver.utils import solver_utils
  from delta.utils.solver.base_solver import Solver
  from delta.utils.solver.utils.callbacks import ParallelModelCheckpoint
  from delta.utils.register import registers
label_desc: Use image node_id 8 for calling the KerasBaseSolver obj's underlying member method code with example usage: obj.model_fn(mode) without return types