def _count_valid_files_in_directory(directory, white_list_formats, split, follow_links):
    'Counts files with extension in `white_list_formats` contained in `directory`.\n\n    # Arguments\n        directory: absolute path to the directory\n            containing files to be counted\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        follow_links: boolean.\n\n    # Returns\n        the count of files with extension in `white_list_formats` contained in\n        the directory.\n    '
    num_files = len(list(_iter_valid_files(directory, white_list_formats, follow_links)))
    if split:
        (start, stop) = (int((split[0] * num_files)), int((split[1] * num_files)))
    else:
        (start, stop) = (0, num_files)
    return (stop - start)
Counts files with extension in `white_list_formats` contained in `directory`.

# Arguments
    directory: absolute path to the directory
        containing files to be counted
    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.
    follow_links: boolean.

# Returns
    the count of files with extension in `white_list_formats` contained in
    the directory.
def _count_valid_files_in_directory(directory, white_list_formats, split, follow_links):
    'Counts files with extension in `white_list_formats` contained in `directory`.\n\n    # Arguments\n        directory: absolute path to the directory\n            containing files to be counted\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        follow_links: boolean.\n\n    # Returns\n        the count of files with extension in `white_list_formats` contained in\n        the directory.\n    '
    num_files = len(list(_iter_valid_files(directory, white_list_formats, follow_links)))
    if split:
        (start, stop) = (int((split[0] * num_files)), int((split[1] * num_files)))
    else:
        (start, stop) = (0, num_files)
    return (stop - start)