def _make_dataset(
    directory: str,
    extensions: Optional[Tuple[str, ...]] = None,
    is_valid_file: Optional[Callable[[str], bool]] = None,
) -> List[Tuple[str, int]]:
    """Create a list of valid image files in the given directory.

    Args:
        directory:
            Root directory path containing image files (should not contain subdirectories).
        extensions:
            Tuple of valid file extensions. If None, is_valid_file must be used.
        is_valid_file:
            Optional function to validate file paths beyond extension checking.

    Returns:
        A list of tuples, where each tuple contains:
        - Full path to an image file
        - Target label (always 0 in this implementation)

    Raises:
        ValueError: If both extensions and is_valid_file are None.
    """
    if extensions is None:
        if is_valid_file is None:
            raise ValueError("Both extensions and is_valid_file cannot be None")
        _is_valid_file = is_valid_file
    else:

        def is_valid_file_extension(filepath: str) -> bool:
            return filepath.lower().endswith(extensions)

        if is_valid_file is None:
            _is_valid_file = is_valid_file_extension
        else:

            def _is_valid_file(filepath: str) -> bool:
                return is_valid_file_extension(filepath) and is_valid_file(filepath)

    instances: List[Tuple[str, int]] = []
    for f in os.scandir(directory):
        if not _is_valid_file(f.path):
            continue

        # convention: the label of all images is 0, based on the fact that
        # they are all in the same directory
        item = (f.path, 0)
        instances.append(item)

    return sorted(instances, key=lambda x: x[0])  # sort by path
Create a list of valid image files in the given directory.

    Args:
        directory:
            Root directory path containing image files (should not contain subdirectories).
        extensions:
            Tuple of valid file extensions. If None, is_valid_file must be used.
        is_valid_file:
            Optional function to validate file paths beyond extension checking.

    Returns:
        A list of tuples, where each tuple contains:
        - Full path to an image file
        - Target label (always 0 in this implementation)

    Raises:
        ValueError: If both extensions and is_valid_file are None.
    
lightly/data/_image.py