def _check_save_dir_empty(save_dir):
    """Make sure a BaseConcatDataset can be saved under a given directory.

    Parameters
    ----------
    save_dir : str
        Directory under which a `BaseConcatDataset` will be saved.

    Raises
    -------
    FileExistsError
        If ``save_dir`` is not a valid directory for saving.
    """
    sub_dirs = [
        os.path.basename(s).isdigit() for s in glob(os.path.join(save_dir, "*"))
    ]
    if any(sub_dirs):
        raise FileExistsError(
            f"Directory {save_dir} already contains subdirectories. Please "
            "select a different directory, set overwrite=True, or resolve "
            "manually."
        )
Make sure a BaseConcatDataset can be saved under a given directory.

    Parameters
    ----------
    save_dir : str
        Directory under which a `BaseConcatDataset` will be saved.

    Raises
    -------
    FileExistsError
        If ``save_dir`` is not a valid directory for saving.
    
braindecode/datautil/serialization.py