class_docstr: Model checkpointer which saves the best model according to the given configurations. `filepath` can contain
  named formatting options, which will be filled any values from state. For example: if `filepath` is
  `weights.{epoch:02d}-{val_loss:.2f}`, then the model checkpoints will be saved with the epoch number and the
  validation loss in the filename.
  
  Example: ::
  
      >>> from torchbearer.callbacks import Best
      >>> from torchbearer import Trial
      >>> import torch
  
      # Example Trial (without optimiser or loss criterion) which uses this checkpointer
      >>> model = torch.nn.Linear(1,1)
      >>> checkpoint = Best('my_path.pt', monitor='val_acc', mode='max')
      >>> trial = Trial(model, callbacks=[checkpoint], metrics=['acc'])
  
  Args:
      filepath (str): Path to save the model file
      save_model_params_only (bool): If `save_model_params_only=True`, only model parameters will be saved so that
          the results can be loaded into a PyTorch nn.Module. The other option, `save_model_params_only=False`,
          should be used only if the results will be loaded into a Torchbearer Trial object later.
      monitor (str): Quantity to monitor
      mode (str): One of {auto, min, max}. If `save_best_only=True`, the decision to overwrite the current save file
          is made based on either the maximization or the minimization of the monitored quantity. For `val_acc`, this
          should be `max`, for `val_loss` this should be `min`, etc. In `auto` mode, the direction is automatically
          inferred from the name of the monitored quantity.
      period (int): Interval (number of epochs) between checkpoints
      min_delta (float): If `save_best_only=True`, this is the minimum improvement required to trigger a save
      pickle_module (module): The pickle module to use, default is 'torch.serialization.pickle'
      pickle_protocol (int): The pickle protocol to use, default is 'torch.serialization.DEFAULT_PROTOCOL'
  
  State Requirements:
      - :attr:`torchbearer.state.MODEL`: Model should have the `state_dict` method
      - :attr:`torchbearer.state.METRICS`: Metrics dictionary should exist, with the `monitor` key populated
      - :attr:`torchbearer.state.SELF`: Self should be the :attr:`torchbearer.Trial` which is running this callback
class_docstr_tok: ["Model","checkpointer","which","saves","the","best","model","according","to","the","given","configurations",".","`","filepath","`","can","contain","named","formatting","options",",","which","will","be","filled","any","values","from","state",".","For","example",":","if","`","filepath","`","is","`","weights",".","{","epoch:02d","}","-","{","val_loss",":",".2f","}","`",",","then","the","model","checkpoints","will","be","saved","with","the","epoch","number","and","the","validation","loss","in","the","filename",".","Example",":",":",":",">",">",">","from","torchbearer.callbacks","import","Best",">",">",">","from","torchbearer","import","Trial",">",">",">","import","torch","#","Example","Trial","(","without","optimiser","or","loss","criterion",")","which","uses","this","checkpointer",">",">",">","model","=","torch.nn.Linear","(","1,1",")",">",">",">","checkpoint","=","Best","(","'my_path.pt","'",",","monitor='val_acc","'",",","mode='max","'",")",">",">",">","trial","=","Trial","(","model",",","callbacks=","[","checkpoint","]",",","metrics=","[","'acc","'","]",")","Args",":","filepath","(","str",")",":","Path","to","save","the","model","file","save_model_params_only","(","bool",")",":","If","`","save_model_params_only=True","`",",","only","model","parameters","will","be","saved","so","that","the","results","can","be","loaded","into","a","PyTorch","nn.Module",".","The","other","option",",","`","save_model_params_only=False","`",",","should","be","used","only","if","the","results","will","be","loaded","into","a","Torchbearer","Trial","object","later",".","monitor","(","str",")",":","Quantity","to","monitor","mode","(","str",")",":","One","of","{","auto",",","min",",","max","}",".","If","`","save_best_only=True","`",",","the","decision","to","overwrite","the","current","save","file","is","made","based","on","either","the","maximization","or","the","minimization","of","the","monitored","quantity",".","For","`","val_acc","`",",","this","should","be","`","max","`",",","for","`","val_loss","`","this","should","be","`","min","`",",","etc",".","In","`","auto","`","mode",",","the","direction","is","automatically","inferred","from","the","name","of","the","monitored","quantity",".","period","(","int",")",":","Interval","(","number","of","epochs",")","between","checkpoints","min_delta","(","float",")",":","If","`","save_best_only=True","`",",","this","is","the","minimum","improvement","required","to","trigger","a","save","pickle_module","(","module",")",":","The","pickle","module","to","use",",","default","is","'torch.serialization.pickle'","pickle_protocol","(","int",")",":","The","pickle","protocol","to","use",",","default","is","'torch.serialization.DEFAULT_PROTOCOL'","State","Requirements",":","-",":","attr",":","`","torchbearer.state.MODEL","`",":","Model","should","have","the","`","state_dict","`","method","-",":","attr",":","`","torchbearer.state.METRICS","`",":","Metrics","dictionary","should","exist",",","with","the","`","monitor","`","key","populated","-",":","attr",":","`","torchbearer.state.SELF","`",":","Self","should","be","the",":","attr",":","`","torchbearer.Trial","`","which","is","running","this","callback"]
code: def on_checkpoint(self, state):
      super(Best, self).on_end_epoch(state)
      self.epochs_since_last_save += 1
      if self.epochs_since_last_save >= self.period:
          self.epochs_since_last_save = 0
  
          current = get_metric("Best Checkpoint", state, self.monitor)
          if current is None:
              return
  
          if self.monitor_op(current, self.best):
              self.best = current
              self.save_checkpoint(state, overwrite_most_recent=True)
  
imports: import torchbearer
  import torch
  from torchbearer.callbacks.callbacks import Callback
  import os
  import warnings
  from torchbearer.bases import get_metric
label_desc: Use image node_id 5 for calling the Best obj's underlying member method code with example usage: obj.on_checkpoint(state) without return types