def load_config(
    path: Union[str, Path],
    ordered: bool = False,
    data_format: str = None,
    encoding: str = "utf-8",
) -> Union[Dict, List]:
    """
    Loads config by giving path. Supports YAML and JSON files.

    Examples:
        >>> load(path="./config.yml", ordered=True)

    Args:
        path: path to config file (YAML or JSON)
        ordered: if true the config will be loaded as ``OrderedDict``
        data_format: ``yaml``, ``yml`` or ``json``.
        encoding: encoding to read the config

    Returns:
        Union[Dict, List]: config

    Raises:
        ValueError: if path ``path`` doesn't exists
            or file format is not YAML or JSON
    """
    path = Path(path)

    if not path.exists():
        raise ValueError(f"Path '{path}' doesn't exist!")

    if data_format is not None:
        suffix = data_format.lower()
        if not suffix.startswith("."):
            suffix = f".{suffix}"
    else:
        suffix = path.suffix

    assert suffix in [".json", ".yml", ".yaml"], f"Unknown file format '{suffix}'"

    config = None
    with path.open(encoding=encoding) as stream:
        if suffix == ".json":
            object_pairs_hook = OrderedDict if ordered else None
            file = "\n".join(stream.readlines())
            if file != "":
                config = json.loads(file, object_pairs_hook=object_pairs_hook)

        elif suffix in [".yml", ".yaml"]:
            assert SETTINGS.yaml_required, YAML_MESSAGE
            loader = OrderedLoader if ordered else yaml.SafeLoader
            config = yaml.load(stream, loader)

    if config is None:
        return {}

    return config

    Loads config by giving path. Supports YAML and JSON files.

    Examples:
        >>> load(path="./config.yml", ordered=True)

    Args:
        path: path to config file (YAML or JSON)
        ordered: if true the config will be loaded as ``OrderedDict``
        data_format: ``yaml``, ``yml`` or ``json``.
        encoding: encoding to read the config

    Returns:
        Union[Dict, List]: config

    Raises:
        ValueError: if path ``path`` doesn't exists
            or file format is not YAML or JSON
    
catalyst/utils/config.py