def from_float(cls, mod: _nn.Module) -> _nn.Module:
        r"""Create a qat module from a float module or qparams_dict

        Args: `mod` a float module, either produced by torch.quantization utilities
        or directly from user
        """
        assert type(mod) == cls._FLOAT_MODULE, (
            "qat." + cls.__name__ + ".from_float only works for " + cls._FLOAT_MODULE.__name__
        )
        assert hasattr(mod, "qconfig"), "Input float module must have qconfig defined"
        assert mod.qconfig, "Input float module must have a valid qconfig"

        assert isinstance(
            mod.weight, _nn.Parameter
        ), "CANNOT be prepared for palettization: weight is NOT learnable"

        qconfig = mod.qconfig
        qat = cls(mod.normalized_shape, eps=mod.eps, elementwise_affine=mod.elementwise_affine)
        qat.qconfig = qconfig

        if qat.elementwise_affine:
            qat.weight_fake_quant = qconfig.weight()

        for name, param in mod.named_parameters(recurse=False):
            setattr(qat, name, param)

        assert qat.elementwise_affine == (qat.weight is not None)
        return qat
Create a qat module from a float module or qparams_dict

        Args: `mod` a float module, either produced by torch.quantization utilities
        or directly from user
        
coremltools/optimize/torch/palettization/_supported_modules.py