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 prediction samples.
docstr_tok: ["Log","prediction","samples","."]
code: def _wandb_log_predictions(self) -> None:
      """Log prediction samples."""
      pred_log = []
  
      if self.validation_data is None:
          return
  
      for x, y in self.validation_data:
          try:
              pred = self.learn.predict(x)
          except Exception:
              raise FastaiError(
                  'Unable to run "predict" method from Learner to log prediction samples.'
              )
  
          # scalar -> likely to be a category
          # tensor of dim 1 -> likely to be multicategory
          if not pred[1].shape or pred[1].dim() == 1:
              pred_log.append(
                  wandb.Image(
                      x.data,
                      caption=f"Ground Truth: {y}\nPrediction: {pred[0]}",
                  )
              )
  
          # most vision datasets have a "show" function we can use
          elif hasattr(x, "show"):
              # log input data
              pred_log.append(
                  wandb.Image(x.data, caption="Input data", grouping=3)
              )
  
              # log label and prediction
              for im, capt in (
                  (pred[0], "Prediction"),
                  (y, "Ground Truth"),
              ):
                  # Resize plot to image resolution
                  # from https://stackoverflow.com/a/13714915
                  my_dpi = 100
                  fig = plt.figure(frameon=False, dpi=my_dpi)
                  h, w = x.size
                  fig.set_size_inches(w / my_dpi, h / my_dpi)
                  ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
                  ax.set_axis_off()
                  fig.add_axes(ax)
  
                  # Superpose label or prediction to input image
                  x.show(ax=ax, y=im)
                  pred_log.append(wandb.Image(fig, caption=capt))
                  plt.close(fig)
  
          # likely to be an image
          elif hasattr(y, "shape") and (
              (len(y.shape) == 2)
              or (len(y.shape) == 3 and y.shape[0] in [1, 3, 4])
          ):
              pred_log.extend(
                  [
                      wandb.Image(
                          x.data, caption="Input data", grouping=3
                      ),
                      wandb.Image(pred[0].data, caption="Prediction"),
                      wandb.Image(y.data, caption="Ground Truth"),
                  ]
              )
  
          # we just log input data
          else:
              pred_log.append(wandb.Image(x.data, caption="Input data"))
  
          wandb.log({"Prediction Samples": pred_log}, commit=False)
  
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 5 for calling the WandbCallback obj's underlying member method code with example usage: obj._wandb_log_predictions() without return types