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.num_embeddings,
            mod.embedding_dim,
            mod.padding_idx,
            max_norm=mod.max_norm,
            norm_type=mod.norm_type,
            scale_grad_by_freq=mod.scale_grad_by_freq,
            sparse=mod.sparse,
            _weight=None,
        )
        qat.qconfig = qconfig
        qat.weight_fake_quant = qconfig.weight()

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

        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