def convert(model, inplace=False):
    r"""
    Convert an FP32 prepared model to a model which will automatically insert fake quant
    before a quantizable module or operator.

    Args:
        model (torch.nn.Module): The FP32 model to be convert.
        inplace: (bool): It will change the given model in-place if True. The default value is ``False``.

    Returns:
        torch.nn.Module
    """
    assert isinstance(
        model, torch.nn.Module
    ), "Only support nn.Module convert for quantization path"
    assert hasattr(
        model, "q_config"
    ), "Please do prepare the model before doing convert"

    if inplace:
        convert_model = model
    else:
        try:
            convert_model = copy_prepared_model(model)
        except BaseException:
            AssertionError(
                False
            ), "The model's copy is failed, please try set inplace to True to do the convert"

    # For weight only quantization. Activation's observer is also PlaceholderObserver.
    if (
        isinstance(convert_model.q_config.activation(), PlaceholderObserver)
        and not convert_model.q_config.activation().is_dynamic
    ):
        qconfig_spec = {
            torch.nn.Linear: convert_model.q_config,
            torch.nn.LSTM: convert_model.q_config,
            torch.nn.GRU: convert_model.q_config,
            torch.nn.LSTMCell: convert_model.q_config,
            torch.nn.RNNCell: convert_model.q_config,
            torch.nn.GRUCell: convert_model.q_config,
        }
        module_mappings = get_default_dynamic_quant_module_mappings().copy()
        module_mappings[torch.nn.Linear] = (
            nn.modules.weight_only_quantization.WeightOnlyQuantizedLinear
        )

        module_mappings, qconfig_spec = may_quantize_deepspeed_modules(
            IPEX_WEIGHT_ONLY_QUANTIZATION_MODULE_CPU(),
            convert_model.q_config,
            module_mappings,
            qconfig_spec,
        )
        converted_model = torch.quantization.quantize_dynamic(
            convert_model,
            qconfig_spec=qconfig_spec,
            dtype=torch.qint8,
            mapping=module_mappings,
            inplace=inplace,
        )
        return converted_model

    # If the module's activation's qconfig is PlaceholderObserver,
    # we can say that the module want to run dynamic quantization path.
    if isinstance(convert_model.q_config.activation(), PlaceholderObserver):
        module_mappings = get_default_dynamic_quant_module_mappings()
        qconfig_spec = {
            torch.nn.Linear: convert_model.q_config,
            torch.nn.LSTM: convert_model.q_config,
            torch.nn.GRU: convert_model.q_config,
            torch.nn.LSTMCell: convert_model.q_config,
            torch.nn.RNNCell: convert_model.q_config,
            torch.nn.GRUCell: convert_model.q_config,
        }

        module_mappings, qconfig_spec = may_quantize_deepspeed_modules(
            IPEX_DYNAMIC_QUANTIZATION_MODULE_CPU(),
            convert_model.q_config,
            module_mappings,
            qconfig_spec,
        )

        return torch.quantization.quantize_dynamic(
            convert_model,
            qconfig_spec=qconfig_spec,
            mapping=module_mappings,
            inplace=True,
        )

    # Convert linear, conv, and Embedding's weight dtype when use autocast,
    # which will reduce the dtype conversion.
    # TODO: check whether can be removed or not?
    if (
        torch.torch.is_autocast_enabled("cpu")
        and torch.get_autocast_dtype("cpu") == torch.bfloat16
    ):
        convert_model = nn.utils._model_convert.convert_model_data_type(
            convert_model, torch.bfloat16
        )[1]

    convert_model = auto_convert(convert_model)
    return convert_model

    Convert an FP32 prepared model to a model which will automatically insert fake quant
    before a quantizable module or operator.

    Args:
        model (torch.nn.Module): The FP32 model to be convert.
        inplace: (bool): It will change the given model in-place if True. The default value is ``False``.

    Returns:
        torch.nn.Module
    
intel_extension_for_pytorch/quantization/_quantize.py