class_docstr: Restore the weights of the best model at the end of the training depending on a monitored quantity.
  
  Args:
      monitor (str): Quantity to monitor. (Default value = 'val_loss')
      mode (str): One of {'min', 'max'}.
          Whether the monitored has to be maximized or minimized. For instance, for `val_accuracy`,
          this should be `max`, and for `val_loss`, this should be `min`, etc.
          (Default value = 'min')
      verbose (bool): Whether to display a message when the model has improved or when restoring
          the best model.
          (Default value = False)
code: def __init__(
      self,
      *,
      monitor: str = "val_loss",
      mode: str = "min",
      verbose: bool = False,
  ):
      super().__init__()
      self.monitor = monitor
  
      if mode not in ["min", "max"]:
          raise ValueError(f"Invalid mode '{mode}'")
      if mode == "min":
          self.monitor_op = lambda x, y: x < y
          self.current_best = float("Inf")
      elif mode == "max":
          self.monitor_op = lambda x, y: x > y
          self.current_best = -float("Inf")
      self.best_weights = None
      self.verbose = verbose
  
imports: import warnings
  from typing import Dict
  from poutyne.framework.callbacks.callbacks import Callback
label_desc: Use image node_id 1 to create a new BestModelRestore object from inherited base classes: Callback with example: obj = BestModelRestore()