code: def filter_valid_files(
      files: Union[PATH_TYPE, List[PATH_TYPE]],
      *additional_lists: List[Any],
      valid_extensions: Optional[Tuple[str, ...]] = None,
  ) -> Union[List[Any], Tuple[List[Any], ...]]:
      """Filter the given list of files and any additional lists to include only the entries that contain a file with a
      valid extension.
  
      Args:
          files: The list of files to filter by.
          additional_lists: Any additional lists to be filtered together with files.
          valid_extensions: The tuple of valid file extensions.
  
      Returns:
          The filtered lists.
  
      """
      if not isinstance(files, List):
          files = [files]
  
      if valid_extensions is None:
          return (files,) + additional_lists
  
      if not isinstance(valid_extensions, tuple):
          valid_extensions = tuple(valid_extensions)
  
      additional_lists = tuple(
          [a] if not isinstance(a, List) else a
          for a in additional_lists
      )
  
      if not all(len(a) == len(files) for a in additional_lists):
          raise ValueError(
              f"The number of files ({len(files)}) and the number of items in any additional lists must be the same."
          )
  
      filtered = list(
          filter(
              lambda sample: has_file_allowed_extension(
                  sample[0], valid_extensions
              ),
              zip(files, *additional_lists),
          )
      )
  
      filtered_files = [f[0] for f in filtered]
  
      invalid = [f for f in files if f not in filtered_files]
  
      if invalid:
          invalid_extensions = list(
              {"." + f.split(".")[-1] for f in invalid}
          )
          rank_zero_warn(
              f"Found invalid file extensions: {', '.join(invalid_extensions)}. "
              "Files with these extensions will be ignored. "
              f"The supported file extensions are: {', '.join(valid_extensions)}."
          )
  
      if additional_lists:
          return tuple(zip(*filtered))
  
      return filtered_files
  
file_path: lightning-flash/src/flash/core/data/utilities/paths.py
imports: import os
  from typing import Any, Callable, List, Optional, Tuple, Union, cast
  from pytorch_lightning.utilities import rank_zero_warn
  from flash.core.data.utilities.sort import sorted_alphanumeric
label_desc: Use image node_id 6 for calling a global function with example usage: filter_valid_files(files) and returns: filtered_files, unknown, tuple