def from_int4_weight(
        cls,
        qweight,
        scales,
        zero_points,
        in_features,
        out_features,
        quant_method,
        qconfig=None,
        bias=None,
        group_size=-1,
        g_idx=None,
    ):
        r"""Create a weight-only quantized module from int4 weight including autoAWQ and autoGPTQ format

        Args:
            qweight (Tensor): tensor in int32 dtype and contains actually int4 data
            scales (Tensor): scales for qweight
            zero_points (Tensor): zero points for qweight
            bias (Tensor or None): bias for linear
            in_features (int): size of each input sample
            out_features (int): size of each output sample
            qconfig (object): Defining the IPEX quantization recipe for Weight only quantization.
                Default value is ``None``.
            group_size: Group size for weight quantization
            g_idx: Indices of groups for each input channel of weight. Generated by
                GPTQ with act-order.
        """

        lowp_mode = WoqLowpMode.BF16
        act_quant_mode = WoqActQuantMode.PER_IC_BLOCK
        cache_weight_for_large_batch = False
        if qconfig is not None and hasattr(qconfig, "global_qconfig"):
            if hasattr(qconfig.global_qconfig, "lowp_mode"):
                lowp_mode = qconfig.global_qconfig.lowp_mode
            if hasattr(qconfig.global_qconfig, "act_quant_mode"):
                act_quant_mode = qconfig.global_qconfig.act_quant_mode
            if hasattr(qconfig.global_qconfig, "cache_weight_for_large_batch"):
                cache_weight_for_large_batch = (
                    qconfig.global_qconfig.cache_weight_for_large_batch
                    and lowp_mode in (WoqLowpMode.BF16, WoqLowpMode.INT8)
                )

        w_dtype = qweight.dtype
        supported_qw_dtype = [
            torch.int32,
            torch.uint8,
            torch.quint4x2,
        ]
        assert (
            w_dtype in supported_qw_dtype
        ), "Data type of int4 weight should be in {}, but got: {}".format(
            supported_qw_dtype, w_dtype
        )

        qlinear = cls(in_features, out_features, dtype=WoqWeightDtype.INT4)
        weight_format = WoqWeightFormat.PLAIN_FORMAT
        if quant_method == QuantMethod.AWQ_GEMM:
            scales, zero_points = _convert_awq_scales_qzeros(scales, zero_points)
            weight_format = WoqWeightFormat.AWQ_FORMAT
        elif quant_method == QuantMethod.GPTQ_GEMM:
            if g_idx is not None:
                qweight, scales, zero_points = _convert_optimum_format_to_desired(
                    qweight, scales, zero_points, inplace=False
                )
            else:
                scales, zero_points = _convert_gptq_scales_qzeros(scales, zero_points)
                weight_format = WoqWeightFormat.GPTQ_FORMAT

        if bias is not None and torch.count_nonzero(bias) == 0:
            bias = None
        qlinear._op_context = torch.ops.ipex_prepack.weight_only_qlinear_prepack_int4(
            qweight,
            scales,
            zero_points,
            bias,
            g_idx,
            None,
            group_size,
            int(lowp_mode),
            act_quant_mode,
            cache_weight_for_large_batch,
            weight_format,
        )
        qlinear.weight = qlinear._op_context.get_weight()
        qlinear.bias = bias is not None
        qlinear._lowp_mode = lowp_mode
        qlinear._act_quant_mode = act_quant_mode
        qlinear._group_size = group_size
        qlinear._cache_weight_for_large_batch = cache_weight_for_large_batch
        qlinear._weight_qscheme = (
            WoqWeightQScheme.ASYMMETRIC
            if zero_points is not None
            else WoqWeightQScheme.SYMMETRIC
        )
        del qweight
        return qlinear
Create a weight-only quantized module from int4 weight including autoAWQ and autoGPTQ format

        Args:
            qweight (Tensor): tensor in int32 dtype and contains actually int4 data
            scales (Tensor): scales for qweight
            zero_points (Tensor): zero points for qweight
            bias (Tensor or None): bias for linear
            in_features (int): size of each input sample
            out_features (int): size of each output sample
            qconfig (object): Defining the IPEX quantization recipe for Weight only quantization.
                Default value is ``None``.
            group_size: Group size for weight quantization
            g_idx: Indices of groups for each input channel of weight. Generated by
                GPTQ with act-order.
        
intel_extension_for_pytorch/nn/modules/weight_only_quantization.py