docstr: 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
docstr_tok: ["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"]
code: def from_float(cls, mod):
      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
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  from .palettization_config import SUPPORTED_PYTORCH_QAT_MODULES
label_desc: Use image node_id 2 for calling the LayerNorm obj's underlying member method code with example usage: obj.from_float(cls, mod) and returns: qat