class_docstr: Log objects to Weights and Biases.
code: def __init__(self, opt: Opt, model=None):
      try:
          # wand is a very expensive thing to import. Wait until the
          # last second to import it.
          import wandb
  
      except ImportError:
          raise ImportError("Please run `pip install wandb`.")
  
      name = opt.get("wandb_name")
      project = opt.get(
          "wandb_project"
      ) or datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")
  
      self.run = wandb.init(
          name=name,
          project=project,
          dir=os.path.dirname(opt["model_file"]),
          notes=f"{opt['model_file']}",
          entity=opt.get("wandb_entity"),
          reinit=True,  # in case of preemption
          resume=True,  # requeued runs should be treated as single run
      )
      # suppress wandb's output
      logging.getLogger("wandb").setLevel(logging.ERROR)
  
      if not self.run.resumed:
          task_arg = opt.get("task", None)
          if task_arg:
              if (
                  len(task_arg.split(",")) == 1
              ):  # It gets confusing to parse these args for multitask teachers, so don't.
                  maybe_task_opts = task_arg.split(":")
                  for task_opt in maybe_task_opts:
                      if len(task_opt.split("=")) == 2:
                          k, v = task_opt.split("=")
                          setattr(self.run.config, k, v)
  
          for key, value in opt.items():
              if key not in self.run.config:  # set by task logic
                  if value is None or isinstance(
                      value, (str, numbers.Number, tuple)
                  ):
                      setattr(self.run.config, key, value)
  
      self.model_file = opt.get("model_file", None)
      if model is not None:
          self.run.watch(model)
  
imports: import datetime
  import json
  import numbers
  import os
  import pathlib
  import re
  from typing import Optional
  import parlai.utils.logging
  from parlai.core.metrics import Metric, dict_report, get_metric_display_data
  from parlai.core.opt import Opt
  from parlai.core.params import ParlaiParser
  from parlai.utils.io import PathManager
label_desc: Use image node_id 2 to create a new WandbLogger object from inherited base classes: object with example: obj = WandbLogger(opt, model)