class_docstr: Callback to save the Elegy model or model weights at some frequency.
  
  `ModelCheckpoint` callback is used in conjunction with training using
  `model.fit()` to save a model or weights at some
  interval, so the model or weights can be loaded later to continue the training
  from the state saved.
  
  A few options this callback provides include:
  
  - Whether to only keep the model that has achieved the "best performance" so
      far, or whether to save the model at the end of every epoch regardless of
      performance.
  - Definition of 'best'; which quantity to monitor and whether it should be
      maximized or minimized.
  - The frequency it should save at. Currently, the callback supports saving at
      the end of every epoch, or after a fixed number of training batches.
  
  Example:
  
  ```python
  EPOCHS = 10
  checkpoint_path = '/tmp/checkpoint'
  model_checkpoint_callback = elegy.callbacks.ModelCheckpoint(
      path=checkpoint_path,
      monitor='val_acc',
      mode='max',
      save_best_only=True)
  
  # Model is saved at the end of every epoch, if it's the best seen
  # so far.
  model.fit(epochs=EPOCHS, callbacks=[model_checkpoint_callback])
  
  # The model status (that are considered the best) are loaded into the model.
  model.load(checkpoint_path)
  ```
class_docstr_tok: ["Callback","to","save","the","Elegy","model","or","model","weights","at","some","frequency",".","`","ModelCheckpoint","`","callback","is","used","in","conjunction","with","training","using","`","model.fit","(",")","`","to","save","a","model","or","weights","at","some","interval",",","so","the","model","or","weights","can","be","loaded","later","to","continue","the","training","from","the","state","saved",".","A","few","options","this","callback","provides","include",":","-","Whether","to","only","keep","the","model","that","has","achieved","the","``","best","performance","''","so","far",",","or","whether","to","save","the","model","at","the","end","of","every","epoch","regardless","of","performance",".","-","Definition","of","'best","'",";","which","quantity","to","monitor","and","whether","it","should","be","maximized","or","minimized",".","-","The","frequency","it","should","save","at",".","Currently",",","the","callback","supports","saving","at","the","end","of","every","epoch",",","or","after","a","fixed","number","of","training","batches",".","Example",":","``","`","python","EPOCHS","=","10","checkpoint_path","=","'\/tmp\/checkpoint'","model_checkpoint_callback","=","elegy.callbacks.ModelCheckpoint","(","path=checkpoint_path",",","monitor='val_acc","'",",","mode='max","'",",","save_best_only=True",")","#","Model","is","saved","at","the","end","of","every","epoch",",","if","it","'s","the","best","seen","#","so","far",".","model.fit","(","epochs=EPOCHS",",","callbacks=","[","model_checkpoint_callback","]",")","#","The","model","status","(","that","are","considered","the","best",")","are","loaded","into","the","model",".","model.load","(","checkpoint_path",")","``","`"]
docstr: Saves the model.
  
  Arguments:
      epoch: the epoch this iteration is in.
      logs: the `logs` dict passed in to `on_batch_end` or `on_epoch_end`.
docstr_tok: ["Saves","the","model",".","Arguments",":","epoch",":","the","epoch","this","iteration","is","in",".","logs",":","the","`","logs","`","dict","passed","in","to","`","on_batch_end","`","or","`","on_epoch_end","`","."]
code: def _save_model(self, epoch, logs):
      """Saves the model.
  
      Arguments:
          epoch: the epoch this iteration is in.
          logs: the `logs` dict passed in to `on_batch_end` or `on_epoch_end`.
      """
      logs = logs or {}
  
      if (
          isinstance(self.save_freq, int)
          or self.epochs_since_last_save >= self.period
      ):
          self.epochs_since_last_save = 0
          path = self._get_file_path(epoch, logs)
  
          # try:
          if self.save_best_only:
              current = logs.get(self.monitor)
              if current is None:
                  logging.warning(
                      "Can save best model only with %s available, "
                      "skipping.",
                      self.monitor,
                  )
              else:
                  if self.monitor_op(current, self.best):
                      if self.verbose > 0:
                          print(
                              "\nEpoch %05d: %s improved from %0.5f to %0.5f,"
                              " saving model to %s"
                              % (
                                  epoch + 1,
                                  self.monitor,
                                  self.best,
                                  current,
                                  path,
                              )
                          )
                      self.best = current
                      self.model.save(path)
                  else:
                      if self.verbose > 0:
                          print(
                              "\nEpoch %05d: %s did not improve from %0.5f"
                              % (epoch + 1, self.monitor, self.best)
                          )
          else:
              if self.verbose > 0:
                  print(
                      "\nEpoch %05d: saving model to %s"
                      % (epoch + 1, path)
                  )
  
              self.model.save(path)
  
file_path: elegy/elegy/callbacks/model_checkpoint.py
imports: import logging
  import numpy
  from .callback import Callback
label_desc: Use image node_id 6 for calling the ModelCheckpoint obj's underlying member method code with example usage: obj._save_model(epoch, logs) without return types