def __init__(
        self,
        name: str,
        version: Optional[str] = None,
        catalog: Optional["Catalog"] = None,
        transform: Optional["Transform"] = None,
        tokenizer: Optional[Callable] = None,
        tokenizer_kwargs: Optional[dict[str, Any]] = None,
        num_samples: int = 0,
        dc_settings: Optional[Settings] = None,
        remove_prefetched: bool = False,
    ):
        """
        Pytorch IterableDataset that streams DataChain datasets.

        See Also:
            `DataChain.to_pytorch()` - convert chain to PyTorch Dataset.

        Args:
            name (str): Name of DataChain dataset to stream.
            version (str): Version of DataChain dataset to stream.
            catalog (Catalog): DataChain catalog to which dataset belongs.
            transform (Transform): Torchvision transforms to apply to the dataset.
            tokenizer (Callable): Tokenizer to use to tokenize text values.
            tokenizer_kwargs (dict): Additional kwargs to pass when calling tokenizer.
            num_samples (int): Number of random samples to draw for each epoch.
                This argument is ignored if `num_samples=0` (the default).
        """
        self.name = name
        self.version = version
        self.transform = transform or DEFAULT_TRANSFORM
        self.tokenizer = tokenizer
        self.tokenizer_kwargs = tokenizer_kwargs or {}
        self.num_samples = num_samples
        if catalog is None:
            catalog = get_catalog()
        self._init_catalog(catalog)

        dc_settings = dc_settings or Settings()
        self.cache = dc_settings.cache
        if (prefetch := dc_settings.prefetch) is not None:
            self.prefetch = prefetch

        self._cache = catalog.cache
        self._prefetch_cache: Optional[Cache] = None
        self._remove_prefetched = remove_prefetched
        if prefetch and not self.cache:
            tmp_dir = catalog.cache.tmp_dir
            assert tmp_dir
            self._prefetch_cache = get_temp_cache(tmp_dir, prefix="prefetch-")
            self._cache = self._prefetch_cache
            weakref.finalize(self, self._prefetch_cache.destroy)

        Pytorch IterableDataset that streams DataChain datasets.

        See Also:
            `DataChain.to_pytorch()` - convert chain to PyTorch Dataset.

        Args:
            name (str): Name of DataChain dataset to stream.
            version (str): Version of DataChain dataset to stream.
            catalog (Catalog): DataChain catalog to which dataset belongs.
            transform (Transform): Torchvision transforms to apply to the dataset.
            tokenizer (Callable): Tokenizer to use to tokenize text values.
            tokenizer_kwargs (dict): Additional kwargs to pass when calling tokenizer.
            num_samples (int): Number of random samples to draw for each epoch.
                This argument is ignored if `num_samples=0` (the default).
        
src/datachain/lib/pytorch.py