def cache(
        self, dataloader: _Iterable, nsamples: int, device: str
    ) -> _Tuple[_List[_torch.Tensor], _Dict[str, _torch.Tensor]]:
        """
        Cache inputs and keyword arguments to be fed to first layer of the model
        which is set up for compression.

        Args:
            dataloader (:py:class:`Iterable`): An iterable where each element
                is an input to the model to be compressed.
            nsamples (:obj:`int`): Number of samples to cache.
            device (:obj:`str`): Device string for device to run compression on.
        """
        inputs = []
        sampled = 0
        for batch in dataloader:
            inputs.append(batch.to(device))
            sampled += 1
            if sampled == nsamples:
                break
        return inputs, {}

        Cache inputs and keyword arguments to be fed to first layer of the model
        which is set up for compression.

        Args:
            dataloader (:py:class:`Iterable`): An iterable where each element
                is an input to the model to be compressed.
            nsamples (:obj:`int`): Number of samples to cache.
            device (:obj:`str`): Device string for device to run compression on.
        
coremltools/optimize/torch/layerwise_compression/input_cacher.py