parameters: (cls, mod)
return_statement: return qat_embedding_bag
docstring: r"""Create a qat module from a float module
  
              Args: `mod` a float module, either produced by torch.ao.quantization utilities
              or directly from user
docstring_summary: r"""Create a qat module from a float module
docstring_tokens: r Create a qat module from a float module
function: def from_float(cls, mod):
          r"""Create a qat module from a float module
  
              Args: `mod` a float module, either produced by torch.ao.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 mod.qconfig.weight().qscheme == torch.per_channel_affine_float_qparams, \
              'Embedding weights requires a qscheme of torch.per_channel_affine_float_qparams Got ' + \
              str(mod.qconfig.weight().qscheme)
  
          qconfig = mod.qconfig
          qat_embedding_bag = cls(mod.num_embeddings, mod.embedding_dim, mod.padding_idx,
                                  mod.max_norm, mod.norm_type, mod.scale_grad_by_freq,
                                  mod.sparse, mod.weight, qconfig=qconfig)
  
          return qat_embedding_bag
function_tokens: def from_float ( cls , mod ) : 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 mod . qconfig . weight ( ) . qscheme == torch . per_channel_affine_float_qparams , 'Embedding weights requires a qscheme of torch.per_channel_affine_float_qparams Got ' + str ( mod . qconfig . weight ( ) . qscheme ) qconfig = mod . qconfig qat_embedding_bag = cls ( mod . num_embeddings , mod . embedding_dim , mod . padding_idx , mod . max_norm , mod . norm_type , mod . scale_grad_by_freq , mod . sparse , mod . weight , qconfig = qconfig ) return qat_embedding_bag