def from_quantization_config(
        cls,
        quantization_config: _Optional[_ModuleLinearQuantizerConfig],
    ) -> _Optional["AnnotationConfig"]:
        """
        Creates a :py:class:`AnnotationConfig` from ``ModuleLinearQuantizerConfig``
        """
        if (
            quantization_config is None
            or quantization_config.weight_dtype == _torch.float32
        ):
            return None

        # Activation QSpec
        if quantization_config.activation_dtype == _torch.float32:
            output_activation_qspec = None
        else:
            activation_qscheme = _QuantizationScheme.get_qscheme(
                quantization_config.quantization_scheme,
                is_per_channel=False,
            )
            activation_dtype = cls._normalize_dtype(
                quantization_config.activation_dtype
            )
            output_activation_qspec = _TorchQuantizationSpec(
                observer_or_fake_quant_ctr=_aoquant.FakeQuantize.with_args(
                    observer=_ObserverType.get_observer(
                        quantization_config.activation_observer,
                        is_per_channel=False,
                    ),
                    dtype=activation_dtype,
                    qscheme=activation_qscheme,
                ),
                dtype=activation_dtype,
                qscheme=activation_qscheme,
            )

        # Weight QSpec
        weight_qscheme = _QuantizationScheme.get_qscheme(
            quantization_config.quantization_scheme,
            is_per_channel=quantization_config.weight_per_channel,
        )
        weight_dtype = cls._normalize_dtype(quantization_config.weight_dtype)
        weight_qspec = _TorchQuantizationSpec(
            observer_or_fake_quant_ctr=_aoquant.FakeQuantize.with_args(
                observer=_ObserverType.get_observer(
                    quantization_config.weight_observer,
                    is_per_channel=quantization_config.weight_per_channel,
                ),
                dtype=weight_dtype,
                qscheme=weight_qscheme,
            ),
            dtype=weight_dtype,
            qscheme=weight_qscheme,
        )
        return AnnotationConfig(
            input_activation=output_activation_qspec,
            output_activation=output_activation_qspec,
            weight=weight_qspec,
        )

        Creates a :py:class:`AnnotationConfig` from ``ModuleLinearQuantizerConfig``
        
coremltools/optimize/torch/quantization/_annotation_config.py