def _feed_data(self, dataloader: _Iterable, nsamples: int, device: str):
        """
        Feed data to the model so that the inputs to the first layer can be cached.
        """
        num_sampled = 0
        for batch in dataloader:
            try:
                self._model(batch.to(device))
            except StopExecution:
                pass
            num_sampled += 1
            if num_sampled >= nsamples:
                break

        Feed data to the model so that the inputs to the first layer can be cached.
        
coremltools/optimize/torch/layerwise_compression/input_cacher.py