human
I wrote the below code

    def _recursive_list(subpath):
        return sorted(os.walk(subpath, followlinks=follow_links), key=(lambda tpl: tpl[0]))
    samples = 0
    for (root, _, files) in _recursive_list(directory):
        for fname in files:
            is_valid = False
            for extension in white_list_formats:
                if fname.lower().endswith(('.' + extension)):
                    is_valid = True
                    break
            if is_valid:
                samples += 1
    return samples

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def _count_valid_files_in_directory(directory, white_list_formats, follow_links):