def __init__(
        self,
        root: str,
        loader: Callable[[str], Any] = default_loader,
        extensions: Optional[Tuple[str, ...]] = None,
        transform: Optional[Callable[[Any], Any]] = None,
        target_transform: Optional[Callable[[Any], Any]] = None,
        is_valid_file: Optional[Callable[[str], bool]] = None,
    ):
        """Initialize a DatasetFolder dataset.

        Args:
            root:
                Path to the root directory containing image files.
            loader:
                A function to load an image from a file path. Defaults to default_loader.
            extensions:
                A tuple of allowed file extensions. If None, is_valid_file must be provided.
            transform:
                Optional transform to be applied to the input image.
            target_transform:
                Optional transform to be applied to the target.
            is_valid_file:
                Optional function to validate file paths. If None and extensions is None,
                raises a ValueError.
        """
        super().__init__(root, transform=transform, target_transform=target_transform)

        samples = _make_dataset(self.root, extensions, is_valid_file)
        if len(samples) == 0:
            msg = "Found 0 files in folder: {}\n".format(self.root)
            if extensions is not None:
                msg += "Supported extensions are: {}".format(",".join(extensions))
            raise RuntimeError(msg)

        self.loader = loader
        self.extensions = extensions

        self.samples = samples
        self.targets = [s[1] for s in samples]
Initialize a DatasetFolder dataset.

        Args:
            root:
                Path to the root directory containing image files.
            loader:
                A function to load an image from a file path. Defaults to default_loader.
            extensions:
                A tuple of allowed file extensions. If None, is_valid_file must be provided.
            transform:
                Optional transform to be applied to the input image.
            target_transform:
                Optional transform to be applied to the target.
            is_valid_file:
                Optional function to validate file paths. If None and extensions is None,
                raises a ValueError.
        
lightly/data/_image.py