# Buggy code
def _init(self):
    config = self.config.copy()

    try:
        if config.get("logger_config", {}).get("wandb"):
            logger_config = config.pop("logger_config")
            wandb_config = logger_config.get("wandb").copy()
        else:
            wandb_config = config.pop("wandb").copy()
    except KeyError:
        raise ValueError(
            "Wandb logger specified but no configuration has been passed. "
            "Make sure to include a `wandb` key in your `config` dict "
            "containing at least a `project` specification."
        )

    _set_api_key(wandb_config)

    exclude_results = self._exclude_results.copy()

    # Additional excludes
    additional_excludes = wandb_config.pop("excludes", [])
    exclude_results += additional_excludes

    # Log config keys on each result?
    log_config = wandb_config.pop("log_config", False)
    if not log_config:
        exclude_results += ["config"]

    # Fill trial ID and name
    trial_id = self.trial.trial_id
    trial_name = str(self.trial)

    # Project name for Wandb
    try:
        wandb_project = wandb_config.pop("project")
    except KeyError:
        raise ValueError("You need to specify a `project` in your wandb `config` dict.")

    # Grouping
    wandb_group = wandb_config.pop("group", self.trial.trainable_name)

    wandb_init_kwargs = dict(
        id=trial_id,
        name=trial_name,
        resume=True,
        reinit=True,
        allow_val_change=True,
        group=wandb_group,
        project=wandb_project,
        config=config,
    )
    wandb_init_kwargs.update(wandb_config)

    self._queue = Queue()
    self._wandb = self._logger_process_cls(
        queue=self._queue,
        exclude=exclude_results,
        to_config=self._config_results,
        **wandb_init_kwargs,
    )
    self._wandb.start()


# Traceback (yaml.representer.RepresenterError)
Process _WandbLoggingProcess-1:
Traceback (most recent call last):
File "/usr/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
self.run()
File "[...]/ray/tune/integration/wandb.py", line 127, in run
wandb.init(*self.args, **self.kwargs)
File "[...]/wandb/__init__.py", line 1303, in init
as_defaults=not allow_val_change)
File "[...]/wandb/wandb_config.py", line 333, in _update
self.persist()
File "[...]/wandb/wandb_config.py", line 238, in persist
conf_file.write(str(self))
File "[...]/wandb/wandb_config.py", line 374, in __str__
allow_unicode=True, encoding='utf-8')
File "[...]/yaml/__init__.py", line 290, in dump
return dump_all([data], stream, Dumper=Dumper, **kwds)
File "[...]/yaml/__init__.py", line 278, in dump_all
dumper.represent(data)
File "[...]/yaml/representer.py", line 27, in represent
node = self.represent_data(data)
File "[...]/yaml/representer.py", line 48, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "[...]/yaml/representer.py", line 207, in represent_dict
return self.represent_mapping('tag:yaml.org,2002:map', data)
File "[...]/yaml/representer.py", line 118, in represent_mapping
node_value = self.represent_data(item_value)
File "[...]/yaml/representer.py", line 48, in represent_data
node = self.yaml_representers[data_types[0]](self, data)
File "[...]/yaml/representer.py", line 207, in represent_dict
return self.represent_mapping('tag:yaml.org,2002:map', data)
File "[...]/yaml/representer.py", line 118, in represent_mapping
node_value = self.represent_data(item_value)
File "[...]/yaml/representer.py", line 58, in represent_data
node = self.yaml_representers[None](self, data)
File "[...]/yaml/representer.py", line 231, in represent_undefined
raise RepresenterError("cannot represent an object", data)
yaml.representer.RepresenterError: ('cannot represent an object', <class '__main__.MyCallbacks'>)

# Fixed code
def _init(self):
    config = self.config.copy()

    config.pop("callbacks", None)  # Remove callbacks

    try:
        if config.get("logger_config", {}).get("wandb"):
            logger_config = config.pop("logger_config")
            wandb_config = logger_config.get("wandb").copy()
        else:
            wandb_config = config.pop("wandb").copy()
    except KeyError:
        raise ValueError(
            "Wandb logger specified but no configuration has been passed. "
            "Make sure to include a `wandb` key in your `config` dict "
            "containing at least a `project` specification."
        )

    _set_api_key(wandb_config)

    exclude_results = self._exclude_results.copy()

    # Additional excludes
    additional_excludes = wandb_config.pop("excludes", [])
    exclude_results += additional_excludes

    # Log config keys on each result?
    log_config = wandb_config.pop("log_config", False)
    if not log_config:
        exclude_results += ["config"]

    # Fill trial ID and name
    trial_id = self.trial.trial_id
    trial_name = str(self.trial)

    # Project name for Wandb
    try:
        wandb_project = wandb_config.pop("project")
    except KeyError:
        raise ValueError("You need to specify a `project` in your wandb `config` dict.")

    # Grouping
    wandb_group = wandb_config.pop("group", self.trial.trainable_name)

    wandb_init_kwargs = dict(
        id=trial_id,
        name=trial_name,
        resume=True,
        reinit=True,
        allow_val_change=True,
        group=wandb_group,
        project=wandb_project,
        config=config,
    )
    wandb_init_kwargs.update(wandb_config)

    self._queue = Queue()
    self._wandb = self._logger_process_cls(
        queue=self._queue,
        exclude=exclude_results,
        to_config=self._config_results,
        **wandb_init_kwargs,
    )
    self._wandb.start()