def _get_torch_ao_prepared_model(
        self, example_inputs: _Tuple[_Any, ...], inplace: bool = False
    ):
        """
        Helper method to prepare quantized model :
        Prepares the model for quantization aware training by inserting
            :py:class:`torch.ao.quantization.FakeQuantize` layers in the model in appropriate places.
        """
        if self._is_prepared:
            _logger.warning(
                "Model has already been prepared for QAT. This API call " "will be a no-op."
            )
            return self._model

        if _is_pruner_prepared(self):
            raise RuntimeError(
                "Model has been prepared for pruning. When running joint compression, "
                "first prepare quantizer/palettizer and then pruner, to ensure insertion of "
                "fake quantization layers does not remove pruning forward hooks."
            )
        model = self._get_model_for_compression(inplace=inplace)
        model.train()
        prepare_custom_config = _PrepareCustomConfig().set_non_traceable_module_names(
            self._config.non_traceable_module_names
        )
        prepare_custom_config = prepare_custom_config.set_preserved_attributes(
            self._config.preserved_attributes
        )
        qat_handler = self._qat_configuration_handler_cls(
            prepare_custom_config=prepare_custom_config,
            qconfig_mapping=self._qconfig_mapping,
            backend_config=_get_backend_config(),
            quantization_scheme=self._quantization_scheme,
        )
        return qat_handler.prepare(model, example_inputs)

        Helper method to prepare quantized model :
        Prepares the model for quantization aware training by inserting
            :py:class:`torch.ao.quantization.FakeQuantize` layers in the model in appropriate places.
        
coremltools/optimize/torch/quantization/quantizer.py