docstr: Args:
      get_model (input1, input2, ... -> keras.Model):
          A function which takes tensors, builds and returns a Keras model.
          It will be part of the tower function.
      input_signature ([tf.TensorSpec]): required. The signature for inputs.
      target_signature ([tf.TensorSpec]): required. The signature for the targets tensors.
      input (InputSource | DataFlow): the InputSource or DataFlow where the input data comes from.
      trainer (Trainer): the default will check the number of available GPUs and use them all.
docstr_tok: ["Args",":","get_model","(","input1",",","input2",",","...","-",">","keras.Model",")",":","A","function","which","takes","tensors",",","builds","and","returns","a","Keras","model",".","It","will","be","part","of","the","tower","function",".","input_signature","(","[","tf.TensorSpec","]",")",":","required",".","The","signature","for","inputs",".","target_signature","(","[","tf.TensorSpec","]",")",":","required",".","The","signature","for","the","targets","tensors",".","input","(","InputSource","|","DataFlow",")",":","the","InputSource","or","DataFlow","where","the","input","data","comes","from",".","trainer","(","Trainer",")",":","the","default","will","check","the","number","of","available","GPUs","and","use","them","all","."]
code: def __init__(
      self,
      get_model,
      input_signature=None,
      target_signature=None,
      input=None,
      trainer=None,
  ):
      """
      Args:
          get_model (input1, input2, ... -> keras.Model):
              A function which takes tensors, builds and returns a Keras model.
              It will be part of the tower function.
          input_signature ([tf.TensorSpec]): required. The signature for inputs.
          target_signature ([tf.TensorSpec]): required. The signature for the targets tensors.
          input (InputSource | DataFlow): the InputSource or DataFlow where the input data comes from.
          trainer (Trainer): the default will check the number of available GPUs and use them all.
      """
      self.get_model = get_model
      assert callable(get_model), get_model
      self.input_signature = input_signature
      self.target_signature = target_signature
      if trainer is None:
          nr_gpu = get_nr_gpu()
          if nr_gpu <= 1:
              trainer = SimpleTrainer()
          else:
              # the default multi-gpu trainer
              trainer = SyncMultiGPUTrainerParameterServer(nr_gpu)
      assert isinstance(trainer, Trainer), trainer
      assert not isinstance(trainer, DistributedTrainerBase)
  
      assert input is not None, "Argument 'input' is required!"
      self.input = apply_default_prefetch(input, trainer)
      self.trainer = trainer
  
imports: from contextlib import contextmanager
  import six
  import tensorflow
  from tensorflow import keras
  from ..callbacks import Callback, CallbackToHook, InferenceRunner, InferenceRunnerBase, ScalarStats
  from ..models.regularize import regularize_cost_from_collection
  from ..tfutils.collection import backup_collection, restore_collection
  from ..tfutils.common import get_op_tensor_name
  from ..tfutils.scope_utils import cached_name_scope
  from ..tfutils.summary import add_moving_summary
  from ..tfutils.tower import get_current_tower_context
  from ..train import SimpleTrainer, SyncMultiGPUTrainerParameterServer, Trainer
  from ..train.interface import apply_default_prefetch
  from ..train.trainers import DistributedTrainerBase
  from ..utils import logger
  from ..utils.gpu import get_nr_gpu
label_desc: Use image node_id 1 to create a new KerasModel object from inherited base classes: object with example: obj = KerasModel(get_model, input_signature, target_signature, input, trainer)