def compress(self, dataloader: _Iterable, device: str, inplace: bool = False) -> _nn.Module:
        """
        Compresses model using samples from ``dataloader``.

        Args:
            dataloader (:py:class:`Iterable`): An iterable where each element
                is an input to the model to be compressed.
            device (:obj:`str`): Device string for device to run compression on.
            inplace (:obj:`bool`): If ``True``, model transformations are carried out in-place and
                the original module is mutated, otherwise a copy of the model is mutated and returned.
                Defaults to ``False``.
        """
        self._model = super().compress(dataloader=dataloader, inplace=inplace)
        with _get_eval_model(self._model):
            with _set_torch_flags():
                return self._compress_impl(dataloader, device)

        Compresses model using samples from ``dataloader``.

        Args:
            dataloader (:py:class:`Iterable`): An iterable where each element
                is an input to the model to be compressed.
            device (:obj:`str`): Device string for device to run compression on.
            inplace (:obj:`bool`): If ``True``, model transformations are carried out in-place and
                the original module is mutated, otherwise a copy of the model is mutated and returned.
                Defaults to ``False``.
        
coremltools/optimize/torch/layerwise_compression/layerwise_compressor.py