class_docstr: Callback for logging experiments to Weights and Biases.
  
  Log SB3 experiments to Weights and Biases
      - Added model tracking and uploading
      - Added complete hyperparameters recording
      - Added gradient logging
      - Note that `wandb.init(...)` must be called before the WandbCallback can be used.
  
  Args:
      verbose: The verbosity of sb3 output
      model_save_path: Path to the folder where the model will be saved, The default value is `None` so the model is not logged
      model_save_freq: Frequency to save the model
      gradient_save_freq: Frequency to log gradient. The default value is 0 so the gradients are not logged
      log: What to log. One of "gradients", "parameters", or "all".
code: def __init__(
      self,
      verbose: int = 0,
      model_save_path: Optional[str] = None,
      model_save_freq: int = 0,
      gradient_save_freq: int = 0,
      log: Optional[Literal["gradients", "parameters", "all"]] = "all",
  ) -> None:
      super().__init__(verbose)
      if wandb.run is None:
          raise wandb.Error(
              "You must call wandb.init() before WandbCallback()"
          )
      with wb_telemetry.context() as tel:
          tel.feature.sb3 = True
      self.model_save_freq = model_save_freq
      self.model_save_path = model_save_path
      self.gradient_save_freq = gradient_save_freq
      if log not in ["gradients", "parameters", "all", None]:
          wandb.termwarn(
              "`log` must be one of `None`, 'gradients', 'parameters', or 'all', "
              "falling back to 'all'"
          )
          log = "all"
      self.log = log
      # Create folder if needed
      if self.model_save_path is not None:
          os.makedirs(self.model_save_path, exist_ok=True)
          self.path = os.path.join(self.model_save_path, "model.zip")
      else:
          assert (
              self.model_save_freq == 0
          ), "to use the `model_save_freq` you have to set the `model_save_path` parameter"
  
file_path: wandb/wandb/integration/sb3/sb3.py
imports: import logging
  import os
  import sys
  from typing import Optional
  from stable_baselines3.common.callbacks import BaseCallback
  import wandb
  from wandb.sdk.lib import telemetry
label_desc: Use image node_id 1 to create a new WandbCallback object from inherited base classes: BaseCallback with example: obj = WandbCallback(verbose, model_save_path, model_save_freq, gradient_save_freq, log)