def save_bd5(<EOL>space, filename,<EOL>group_index=<NUM_LIT:0>, object_name="<STR_LIT>", spatial_unit="<STR_LIT>", time_unit="<STR_LIT>",<EOL>trunc=False, with_radius=False):
if isinstance(space, (list, tuple, set)):<EOL><INDENT>for i, space_ in enumerate(space):<EOL><INDENT>assert not isinstance(space_, (list, tuple, set))<EOL>save_bd5(<EOL>space_, filename, group_index + i, object_name, spatial_unit, time_unit,<EOL>trunc if i == <NUM_LIT:0> else False, with_radius)<EOL><DEDENT><DEDENT>elif isinstance(space, str):<EOL><INDENT>save_bd5(load_world(space), filename, group_index, object_name, spatial_unit, time_unit, trunc, with_radius)<EOL><DEDENT>elif isinstance(space, pathlib.PurePath):<EOL><INDENT>save_bd5(str(space), filename, group_index, object_name, spatial_unit, time_unit, trunc, with_radius)<EOL><DEDENT>else:<EOL><INDENT>_save_bd5(space.as_base(), filename, group_index, object_name, spatial_unit, time_unit, trunc, with_radius)<EOL><DEDENT>
Save a space in the BDML-BD5 format (https://github.com/openssbd/BDML-BD5).

    Open file for read/write, if it already exists, and create a new file, otherwise.
    If trunc is True, always create a new file.
    A new group named `group_name` is created. If the group already exists, returns
    an exception.

    Parameters
    ----------
    space : Space, str, pathlib.PurePath, list, tuple or set
        A Space or World to be saved. If str or pathlib.PurePath is given, a space is
        loaded from the given path. If this is an iterable (list, tuple, set), apply
        this function to each element of the given.
    filename : str
        A HDF5 filename.
    group_index : int, optional
        An index of the group written (0, 1, ..., n). Defaults to 0.
    object_name : str, optional
        A name of the object. Its length must be less than 128. Defaults to "molecule".
    spatial_unit : str, optional
        An unit of the length scale. Its length must be less than 16. Defaults to "meter".
    time_unit : str, optional
        An unit of the time scale. Its length must be less than 16. Defaults to "second".
    trunc : bool, optional
        Whether truncate file or not. If True, always overwrite the file when open it.
        Defaults to False.
    with_radius : bool, optional
        Whether save the radius of particles. If True, particles are saved as 'sphere',
        otherwise, as 'point'. Defaults to False.