def dump_yaml(data: Union[str, Dict, List], stream=None):
    """
    Dump YAML file as python object.

    Args:
        data (`Union[str, Dict, List]`):
            The data to write into a YAMl file.
        stream:
            The stream to dump the YAML into.
    """
    yaml = YAML()
    yaml.indent(mapping=4, sequence=8, offset=4)
    yaml.compact_seq_map = False

    if stream is None:
        stream = io.StringIO()
        yaml.dump(data=data, stream=stream)
        return stream.getvalue()
    else:
        yaml.dump(data=data, stream=stream)
Dump YAML file as python object.

Args:
data (`Union[str, Dict, List]`):
The data to write into a YAMl file.
stream:
The stream to dump the YAML into.
towhee/utils/yaml_utils.py