def from_float(cls, mod, scales=None, zero_points=None):
        r"""Create a weight-only quantized module from a float module or qparams_dict

        Args:
            mod (Module): an instance of nn.Linear or its subclasses.
            scales: the scales Tensor for quantizing weight. If it is None,
                scales are found by min/max of the weight.
            zero_points: the zero points Tensor for quantizing weight. If it is None,
                zero points are found by min/max of the weight.
        """
        float_modules = [torch.nn.Linear]
        deepspeed_modules = may_import_deepspeed_modules()
        if deepspeed_modules is not None:
            float_modules.extend(deepspeed_modules)
        if any(issubclass(type(mod), float_module) for float_module in float_modules):
            float_modules.extend([type(mod)])

        assert type(mod) in float_modules, (
            "WeightOnlyQuantizedLinear.from_float only works for one of"
            + str([float_mod.__name__ for float_mod in float_modules])
            + f" or their subclasses, but found {type(mod)}"
        )
        assert hasattr(mod, "qconfig"), "Input float module must have qconfig defined"
        qconfig = mod.qconfig
        if qconfig is None or not isinstance(qconfig, QConfigWoq):
            return mod

        lowp_mode = qconfig.lowp_mode
        act_quant_mode = qconfig.act_quant_mode
        dtype = qconfig.weight_dtype
        group_size = qconfig.group_size
        # if dtype = int8, lowp-mode = int8, we want zero points to be 0
        # otherwise, it may overflow when we subtract zero points from int8 weight.
        sym_quant = qconfig.weight_qscheme == WoqWeightQScheme.SYMMETRIC
        if dtype == WoqWeightDtype.NF4 or (
            dtype == WoqWeightDtype.INT8 and lowp_mode == WoqLowpMode.INT8
        ):
            assert (
                sym_quant is True
            ), "WOQ NF4 and INT8 with lowp-mode 3 must use symmetric quantization"

        if group_size == -1:
            qweight, scales, zero_points = quantize_per_channel(
                mod.weight, dtype, scales, zero_points, sym_quant
            )
        else:
            qweight, scales, zero_points = quantize_per_block(
                mod.weight, dtype, group_size, scales, zero_points, sym_quant
            )
        if not hasattr(mod, "in_features"):
            mod.in_features = mod.weight.size()[1]
        if not hasattr(mod, "out_features"):
            mod.out_features = mod.weight.size()[0]
        cache_weight_for_large_batch = (
            qconfig.cache_weight_for_large_batch and lowp_mode in (2, 3)
        )

        qlinear = cls._init_cls(
            mod,
            dtype,
            qweight,
            scales,
            zero_points,
            None,  # bias, we use mod.bias here
            None,  # g_idx
            group_size,
            lowp_mode,
            act_quant_mode,
            cache_weight_for_large_batch,
            False,  # is_from_int4_weight
        )
        del qweight
        mod.weight = torch.nn.Parameter()
        return qlinear
Create a weight-only quantized module from a float module or qparams_dict

        Args:
            mod (Module): an instance of nn.Linear or its subclasses.
            scales: the scales Tensor for quantizing weight. If it is None,
                scales are found by min/max of the weight.
            zero_points: the zero points Tensor for quantizing weight. If it is None,
                zero points are found by min/max of the weight.
        
intel_extension_for_pytorch/nn/modules/weight_only_quantization.py