class_docstr: Callback for saving model topology, losses & metrics.
  
  Optionally logs weights, gradients, sample predictions and best trained model.
  
  Arguments:
      learn (fastai.basic_train.Learner): the fast.ai learner to hook.
      log (str): "gradients", "parameters", "all", or None. Losses & metrics are always logged.
      save_model (bool): save model at the end of each epoch. It will also load best model at the end of training.
      monitor (str): metric to monitor for saving best model. None uses default TrackerCallback monitor value.
      mode (str): "auto", "min" or "max" to compare "monitor" values and define best model.
      input_type (str): "images" or None. Used to display sample predictions.
      validation_data (list): data used for sample predictions if input_type is set.
      predictions (int): number of predictions to make if input_type is set and validation_data is None.
      seed (int): initialize random generator for sample predictions if input_type is set and validation_data is None.
docstr: Log training loss, validation loss and custom metrics & log prediction samples & save model.
docstr_tok: ["Log","training","loss",",","validation","loss","and","custom","metrics","&","log","prediction","samples","&","save","model","."]
code: def on_epoch_end(
      self,
      epoch: int,
      smooth_loss: float,
      last_metrics: list,
      **kwargs: Any,
  ) -> None:
      """Log training loss, validation loss and custom metrics & log prediction samples & save model."""
      if self.save_model:
          # Adapted from fast.ai "SaveModelCallback"
          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
  
              # Save within wandb folder
              with self.model_path.open("wb") as model_file:
                  self.learn.save(model_file)
  
      # Log sample predictions if learn.predict is available
      if self.validation_data:
          try:
              self._wandb_log_predictions()
          except FastaiError as e:
              wandb.termwarn(e.message)
              self.validation_data = (
                  None  # prevent from trying again on next loop
              )
          except Exception as e:
              wandb.termwarn(f"Unable to log prediction samples.\n{e}")
              self.validation_data = (
                  None  # prevent from trying again on next loop
              )
  
      # Log losses & metrics
      # Adapted from fast.ai "CSVLogger"
      logs = {
          name: stat
          for name, stat in list(
              zip(
                  self.learn.recorder.names,
                  [epoch, smooth_loss] + last_metrics,
              )
          )
      }
      wandb.log(logs)
  
file_path: wandb/wandb/integration/fastai/__init__.py
imports: import random
  import sys
  from pathlib import Path
  from typing import Any, Optional
  import fastai
  from fastai.callbacks import TrackerCallback
  import wandb
label_desc: Use image node_id 3 for calling the WandbCallback obj's underlying member method code with example usage: obj.on_epoch_end(epoch, smooth_loss, last_metrics) without return types