# Buggy code
def log_hyperparams(
    self,
    params: Union[Dict[str, Any], Namespace],
    metrics: Optional[Dict[str, Any]] = None,
) -> None:
    params = self._convert_params(params)

    # store params to output
    self.hparams.update(params)

    # format params into the suitable for tensorboard
    params = self._flatten_dict(params)
    params = self._sanitize_params(params)

    if parse_version(torch.__version__) < parse_version("1.3.0"):
        warn(
            f"Hyperparameter logging is not available for Torch version {torch.__version__}."
            " Skipping log_hyperparams. Upgrade to Torch 1.3.0 or above to enable"
            " hyperparameter logging."
        )
    else:
        from torch.utils.tensorboard.summary import hparams

        if metrics is None:
            metrics = {}
        exp, ssi, sei = hparams(params, metrics)
        writer = self.experiment._get_file_writer()
        writer.add_summary(exp)
        writer.add_summary(ssi)
        writer.add_summary(sei)

        if metrics:
            # necessary for hparam comparison with metrics
            self.log_metrics(metrics)


# Traceback (AttributeError)
-- Process 0 terminated with the following error:
Traceback (most recent call last):
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/torch/multiprocessing/spawn.py", line 20, in _wrap
    fn(i, *args)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/torchelastic/agent/server/local_elastic_agent.py", line
 101, in _wrap
    ret = fn(*args)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/f6/stdlib/sample_projects/classy_hydra_project/main.py"
, line 32, in train
    trainer.fit(task)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/pytorch_lightning/trainer/trainer.py", line 1039, in
 fit
    self.ddp_train(process_idx=task, q=None, model=model)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/pytorch_lightning/trainer/distrib_data_parallel.py",
 line 563, in ddp_train
    results = self.run_pretrain_routine(model)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/pytorch_lightning/trainer/trainer.py", line 1199, in
 run_pretrain_routine
    self.logger.save()
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/pytorch_lightning/utilities/distributed.py", line 12,
 in wrapped_fn
    return fn(*args, **kwargs)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/f6/stdlib/loggers/manifold_tensorboard_logger.py", line
 125, in save
    self.save_hparams_to_yaml(hparams_file, self.hparams)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/f6/stdlib/loggers/manifold_tensorboard_logger.py", line
 151, in save_hparams_to_yaml
    yaml.dump(hparams, fp)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/__init__.py", line 290, in dump
    return dump_all([data], stream, Dumper=Dumper, **kwds)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/__init__.py", line 278, in dump_all
    dumper.represent(data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 27, in represent
    node = self.represent_data(data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 207, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 343, in represent_object
    'tag:yaml.org,2002:python/object:'+function_name, state)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 343, in represent_object
    'tag:yaml.org,2002:python/object:'+function_name, state)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 207, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 343, in represent_object
    'tag:yaml.org,2002:python/object:'+function_name, state)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 207, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 343, in represent_object
    'tag:yaml.org,2002:python/object:'+function_name, state)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 343, in represent_object
    'tag:yaml.org,2002:python/object:'+function_name, state)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 52, in represent_data
    node = self.yaml_multi_representers[data_type](self, data)
  File "/mnt/xarfuse/uid-30415/c18376c8-seed-f10abbe6-4964-43d9-a723-5ecbc73379c7-ns-4026534030/yaml/representer.py", line 331, in represent_object
    if function.__name__ == '__newobj__':
AttributeError: 'str' object has no attribute '__name__'

# Fixed code
def log_hyperparams(
    self,
    params: Union[Dict[str, Any], Namespace],
    metrics: Optional[Dict[str, Any]] = None,
) -> None:
    params = self._convert_params(params)

    # store params to output
    if OMEGACONF_AVAILABLE and isinstance(params, Container):
        self.hparams = OmegaConf.merge(self.hparams, params)
    else:
        self.hparams.update(params)

    # format params into the suitable for tensorboard
    params = self._flatten_dict(params)
    params = self._sanitize_params(params)

    if parse_version(torch.__version__) < parse_version("1.3.0"):
        warn(
            f"Hyperparameter logging is not available for Torch version {torch.__version__}."
            " Skipping log_hyperparams. Upgrade to Torch 1.3.0 or above to enable"
            " hyperparameter logging."
        )
    else:
        from torch.utils.tensorboard.summary import hparams

        if metrics is None:
            metrics = {}
        exp, ssi, sei = hparams(params, metrics)
        writer = self.experiment._get_file_writer()
        writer.add_summary(exp)
        writer.add_summary(ssi)
        writer.add_summary(sei)

        if metrics:
            # necessary for hparam comparison with metrics
            self.log_metrics(metrics)