from typing import Any
from typing import Dict
import yaml


def load_yaml(yaml_filepath: str, safe_load: bool = True, **kwargs: Any) -> Dict:
    """
    Load a YAML file.

    Parameters
    ----------
    yaml_filepath : str
    safe_load : bool, optional (default: True)
        This triggers the usage of yaml.safe_load.
        yaml.load can call any Python function and should only be used if the
        source of the configuration file is trusted.
    **kwargs : Any
        Arbitrary keyword arguments which get passed to the loader functions.

    Returns
    -------
    config : Dict
    """
    with open(yaml_filepath) as stream:
        if safe_load:
            config = yaml.safe_load(stream)
        else:
            config = yaml.load(stream, **kwargs)  # noqa
    return config