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.
code: def __init__(
      self,
      learn: "fastai.basic_train.Learner",
      log: Optional[
          Literal["gradients", "parameters", "all"]
      ] = "gradients",
      save_model: bool = True,
      monitor: Optional[str] = None,
      mode: Literal["auto", "min", "max"] = "auto",
      input_type: Optional[Literal["images"]] = None,
      validation_data: Optional[list] = None,
      predictions: int = 36,
      seed: int = 12345,
  ) -> None:
      # Check if wandb.init has been called
      if wandb.run is None:
          raise ValueError(
              "You must call wandb.init() before WandbCallback()"
          )
  
      # Adapted from fast.ai "SaveModelCallback"
      if monitor is None:
          # use default TrackerCallback monitor value
          super().__init__(learn, mode=mode)
      else:
          super().__init__(learn, monitor=monitor, mode=mode)
      self.save_model = save_model
      self.model_path = Path(wandb.run.dir) / "bestmodel.pth"
  
      self.log = log
      self.input_type = input_type
      self.best = None
  
      # Select items for sample predictions to see evolution along training
      self.validation_data = validation_data
      if input_type and not self.validation_data:
          wandb_random = random.Random(seed)  # For repeatability
          predictions = min(predictions, len(learn.data.valid_ds))
          indices = wandb_random.sample(
              range(len(learn.data.valid_ds)), predictions
          )
          self.validation_data = [
              learn.data.valid_ds[i] for i in indices
          ]
  
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 1 to create a new WandbCallback object from inherited base classes: TrackerCallback with example: obj = WandbCallback(learn, log, save_model, monitor, mode, input_type, validation_data, predictions, seed)