parameters: (directory, white_list_formats,
                                         class_indices, follow_links)
return_statement: return classes, filenames
docstring: List 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.
        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", ...]).
docstring_summary: List paths of files in `subdir` with extensions in `white_list_formats`.
docstring_tokens: List paths of files in subdir with extensions in white_list_formats .
function: def _list_valid_filenames_in_directory(directory, white_list_formats,
                                         class_indices, follow_links):
    """List 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.
        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 _recursive_list(subpath):
      return sorted(
          os.walk(subpath, followlinks=follow_links), key=lambda tpl: tpl[0])
  
    classes = []
    filenames = []
    subdir = os.path.basename(directory)
    basedir = os.path.dirname(directory)
    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:
          classes.append(class_indices[subdir])
          # add filename relative to directory
          absolute_path = os.path.join(root, fname)
          filenames.append(os.path.relpath(absolute_path, basedir))
    return classes, filenames
function_tokens: def _list_valid_filenames_in_directory ( directory , white_list_formats , class_indices , follow_links ) : def _recursive_list ( subpath ) : return sorted ( os . walk ( subpath , followlinks = follow_links ) , key = lambda tpl : tpl [ 0 ] ) classes = [ ] filenames = [ ] subdir = os . path . basename ( directory ) basedir = os . path . dirname ( directory ) 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 : classes . append ( class_indices [ subdir ] ) # add filename relative to directory absolute_path = os . path . join ( root , fname ) filenames . append ( os . path . relpath ( absolute_path , basedir ) ) return classes , filenames