def _list_valid_filenames_in_directory(directory, white_list_formats, split, class_indices, follow_links):
    'Lists paths of files in `subdir` with extensions in `white_list_formats`.\n\n    # Arguments\n        directory: absolute path to a directory containing the files to list.\n            The directory name is used as class label\n            and must be a key of `class_indices`.\n        white_list_formats: set of strings containing allowed extensions for\n            the files to be counted.\n        split: tuple of floats (e.g. `(0.2, 0.6)`) to only take into\n            account a certain fraction of files in each directory.\n            E.g.: `segment=(0.6, 1.0)` would only account for last 40 percent\n            of images in each directory.\n        class_indices: dictionary mapping a class name to its index.\n        follow_links: boolean.\n\n    # Returns\n        classes: a list of class indices\n        filenames: the path of valid files in `directory`, relative from\n            `directory`\'s parent (e.g., if `directory` is "dataset/class1",\n            the filenames will be\n            `["class1/file1.jpg", "class1/file2.jpg", ...]`).\n    '
    dirname = os.path.basename(directory)
    if split:
        num_files = len(list(_iter_valid_files(directory, white_list_formats, follow_links)))
        (start, stop) = (int((split[0] * num_files)), int((split[1] * num_files)))
        valid_files = list(_iter_valid_files(directory, white_list_formats, follow_links))[start:stop]
    else:
        valid_files = _iter_valid_files(directory, white_list_formats, follow_links)
    classes = []
    filenames = []
    for (root, fname) in valid_files:
        classes.append(class_indices[dirname])
        absolute_path = os.path.join(root, fname)
        relative_path = os.path.join(dirname, os.path.relpath(absolute_path, directory))
        filenames.append(relative_path)
    return (classes, filenames)
Lists paths of files in `subdir` with extensions in `white_list_formats`.

# Arguments
    directory: absolute path to a directory containing the files to list.
        The directory name is used as class label
        and must be a key of `class_indices`.
    white_list_formats: set of strings containing allowed extensions for
        the files to be counted.
    split: tuple of floats (e.g. `(0.2, 0.6)`) to only take into
        account a certain fraction of files in each directory.
        E.g.: `segment=(0.6, 1.0)` would only account for last 40 percent
        of images in each directory.
    class_indices: dictionary mapping a class name to its index.
    follow_links: boolean.

# Returns
    classes: a list of class indices
    filenames: the path of valid files in `directory`, relative from
        `directory`'s parent (e.g., if `directory` is "dataset/class1",
        the filenames will be
        `["class1/file1.jpg", "class1/file2.jpg", ...]`).
def _list_valid_filenames_in_directory(directory, white_list_formats, split, class_indices, follow_links):
    'Lists paths of files in `subdir` with extensions in `white_list_formats`.\n\n    # Arguments\n        directory: absolute path to a directory containing the files to list.\n            The directory name is used as class label\n            and must be a key of `class_indices`.\n        white_list_formats: set of strings containing allowed extensions for\n            the files to be counted.\n        split: tuple of floats (e.g. `(0.2, 0.6)`) to only take into\n            account a certain fraction of files in each directory.\n            E.g.: `segment=(0.6, 1.0)` would only account for last 40 percent\n            of images in each directory.\n        class_indices: dictionary mapping a class name to its index.\n        follow_links: boolean.\n\n    # Returns\n        classes: a list of class indices\n        filenames: the path of valid files in `directory`, relative from\n            `directory`\'s parent (e.g., if `directory` is "dataset/class1",\n            the filenames will be\n            `["class1/file1.jpg", "class1/file2.jpg", ...]`).\n    '
    dirname = os.path.basename(directory)
    if split:
        num_files = len(list(_iter_valid_files(directory, white_list_formats, follow_links)))
        (start, stop) = (int((split[0] * num_files)), int((split[1] * num_files)))
        valid_files = list(_iter_valid_files(directory, white_list_formats, follow_links))[start:stop]
    else:
        valid_files = _iter_valid_files(directory, white_list_formats, follow_links)
    classes = []
    filenames = []
    for (root, fname) in valid_files:
        classes.append(class_indices[dirname])
        absolute_path = os.path.join(root, fname)
        relative_path = os.path.join(dirname, os.path.relpath(absolute_path, directory))
        filenames.append(relative_path)
    return (classes, filenames)