code: def list_valid_files(
      paths: Union[PATH_TYPE, List[PATH_TYPE]],
      valid_extensions: Optional[Tuple[str, ...]] = None,
  ) -> List[PATH_TYPE]:
      """List the files with a valid extension present in: a single file, a list of files, or a directory.
  
      Args:
          paths: A single file, a list of files, or a directory.
          valid_extensions: The tuple of valid file extensions.
  
      Returns:
          The list of files present in ``paths`` that have a valid extension.
      """
      if isdir(paths):
          paths = [
              os.path.join(paths, file) for file in os.listdir(paths)
          ]
  
      if not isinstance(paths, list):
          paths = [paths]
  
      if valid_extensions is None:
          return paths
      return [
          path
          for path in paths
          if has_file_allowed_extension(path, valid_extensions)
      ]
  
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 5 for calling a global function with example usage: list_valid_files(paths, valid_extensions) and returns: unknown, paths