def on_epoch_end(self, epoch, smooth_loss, last_metrics, **kwargs):
    'Logs training loss, validation loss and custom metrics & log prediction samples & save model'
    if self.save_model:
        current = self.get_monitor_value()
        if ((current is not None) and self.operator(current, self.best)):
            print('Better model found at epoch {} with {} value: {}.'.format(epoch, self.monitor, current))
            self.best = current
            with self.model_path.open('wb') as model_file:
                self.learn.save(model_file)
    if self.validation_data:
        try:
            self._wandb_log_predictions()
        except FastaiError as e:
            wandb.termwarn(e.message)
            self.validation_data = None
        except Exception as e:
            wandb.termwarn('Unable to log prediction samples.\n{}'.format(e))
            self.validation_data = None
    logs = {name: stat for (name, stat) in list(zip(self.learn.recorder.names, ([epoch, smooth_loss] + last_metrics)))}
    wandb.log(logs)
Logs training loss, validation loss and custom metrics & log prediction samples & save model
def on_epoch_end(self, epoch, smooth_loss, last_metrics, **kwargs):
    
    if self.save_model:
        current = self.get_monitor_value()
        if ((current is not None) and self.operator(current, self.best)):
            print('Better model found at epoch {} with {} value: {}.'.format(epoch, self.monitor, current))
            self.best = current
            with self.model_path.open('wb') as model_file:
                self.learn.save(model_file)
    if self.validation_data:
        try:
            self._wandb_log_predictions()
        except FastaiError as e:
            wandb.termwarn(e.message)
            self.validation_data = None
        except Exception as e:
            wandb.termwarn('Unable to log prediction samples.\n{}'.format(e))
            self.validation_data = None
    logs = {name: stat for (name, stat) in list(zip(self.learn.recorder.names, ([epoch, smooth_loss] + last_metrics)))}
    wandb.log(logs)