def load_yaml(stream, typ: str = 'safe'):
    """
    Load the YAML document in a stream as Python object.

    Args:
        stream:
            The YAML file loaded in a stream.
        typ:
            The type of Dumper/Loader to apply in ruamel.yaml.

    Returns:
        The YAML laoded as python object.
    """
    yaml = YAML(typ=typ)
    data = yaml.load(stream=stream)
    if not isinstance(data, dict):
        raise ValueError(
            'The loaded data should be a dict, please check your yaml source.\
            (Such error is very likely caused by using dash instead of underline in yaml file name.)'
        )

    return data
Load the YAML document in a stream as Python object.

Args:
stream:
The YAML file loaded in a stream.
typ:
The type of Dumper/Loader to apply in ruamel.yaml.

Returns:
The YAML laoded as python object.
towhee/utils/yaml_utils.py