# Buggy code
def load_hparams_from_yaml(config_yaml: str) -> Dict[str, Any]:
    """Load hparams from a file.

    >>> hparams = Namespace(batch_size=32, learning_rate=0.001, data_root='./any/path/here')
    >>> path_yaml = './testing-hparams.yaml'
    >>> save_hparams_to_yaml(path_yaml, hparams)
    >>> hparams_new = load_hparams_from_yaml(path_yaml)
    >>> vars(hparams) == hparams_new
    True
    >>> os.remove(path_yaml)
    """
    fs = get_filesystem(config_yaml)
    if not fs.exists(config_yaml):
        rank_zero_warn(f"Missing Tags: {config_yaml}.", RuntimeWarning)
        return {}

    with fs.open(config_yaml, "r") as fp:
        tags = yaml.full_load(fp)

    return tags


# Traceback (omegaconf.errors.ConfigKeyError)
Traceback (most recent call last):
File "xCoFormer.py", line 153, in perform_tasks
fit(hparams)
File "xCoFormer.py", line 88, in fit
trainer.fit(model, datamodule=dm)
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 470, in fit
results = self.accelerator_backend.train()
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/accelerators/gpu_accelerator.py", line 65, in train
self.trainer.train_loop.setup_training(model)
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/trainer/training_loop.py", line 147, in setup_training
self.trainer.logger.save()
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/utilities/distributed.py", line 39, in wrapped_fn
return fn(*args, **kwargs)
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/loggers/tensorboard.py", line 221, in save
save_hparams_to_yaml(hparams_file, self.hparams)
File "/home/celso/projects/venvs/xCoFormer/lib/python3.7/site-packages/pytorch_lightning/core/saving.py", line 366, in save_hparams_to_yaml
OmegaConf.save(hparams, fp, resolve=True)
omegaconf.errors.ConfigKeyError: str interpolation key 'data.name' not found

# Fixed code
def load_hparams_from_yaml(
    config_yaml: str, use_omegaconf: bool = True
) -> Dict[str, Any]:
    """Load hparams from a file.

        Args:
            config_yaml: Path to config yaml file
            use_omegaconf: If both `OMEGACONF_AVAILABLE` and `use_omegaconf` are True,
                the hparams will be converted to `DictConfig` if possible

    >>> hparams = Namespace(batch_size=32, learning_rate=0.001, data_root='./any/path/here')
    >>> path_yaml = './testing-hparams.yaml'
    >>> save_hparams_to_yaml(path_yaml, hparams)
    >>> hparams_new = load_hparams_from_yaml(path_yaml)
    >>> vars(hparams) == hparams_new
    True
    >>> os.remove(path_yaml)
    """
    fs = get_filesystem(config_yaml)
    if not fs.exists(config_yaml):
        rank_zero_warn(f"Missing Tags: {config_yaml}.", RuntimeWarning)
        return {}

    with fs.open(config_yaml, "r") as fp:
        hparams = yaml.full_load(fp)

    if OMEGACONF_AVAILABLE:
        if use_omegaconf:
            try:
                return OmegaConf.create(hparams)
            except (UnsupportedValueType, ValidationError):
                pass
    return hparams