class_docstr: A quantized Embedding module with quantized packed weights as inputs.
  We adopt the same interface as `torch.nn.Embedding`, please see
  https://pytorch.org/docs/stable/nn.html#torch.nn.Embedding for documentation.
  
  Similar to :class:`~torch.nn.Embedding`, attributes will be randomly
  initialized at module creation time and will be overwritten later
  
  Attributes:
      weight (Tensor): the non-learnable quantized weights of the module of
                       shape :math:`(\text{num\_embeddings}, \text{embedding\_dim})`.
  
  Examples::
      >>> m = nn.quantized.Embedding(num_embeddings=10, embedding_dim=12)
      >>> indices = torch.tensor([9, 6, 5, 7, 8, 8, 9, 2, 8])
      >>> output = m(indices)
      >>> print(output.size())
      torch.Size([9, 12])
class_docstr_tok: ["A","quantized","Embedding","module","with","quantized","packed","weights","as","inputs",".","We","adopt","the","same","interface","as","`","torch.nn.Embedding","`",",","please","see","https",":","\/\/pytorch.org\/docs\/stable\/nn.html","#","torch.nn.Embedding","for","documentation",".","Similar","to",":","class",":","`","~torch.nn.Embedding","`",",","attributes","will","be","randomly","initialized","at","module","creation","time","and","will","be","overwritten","later","Attributes",":","weight","(","Tensor",")",":","the","non-learnable","quantized","weights","of","the","module","of","shape",":","math",":","`","(","\\text","{","num\\_embeddings","}",",","\\text","{","embedding\\_dim","}",")","`",".","Examples",":",":",">",">",">","m","=","nn.quantized.Embedding","(","num_embeddings=10",",","embedding_dim=12",")",">",">",">","indices","=","torch.tensor","(","[","9",",","6",",","5",",","7",",","8",",","8",",","9",",","2",",","8","]",")",">",">",">","output","=","m","(","indices",")",">",">",">","print","(","output.size","(",")",")","torch.Size","(","[","9",",","12","]",")"]
docstr: Create a quantized embedding module from a float module
  
  Args:
      mod (Module): a float module, either produced by torch.ao.quantization
                    utilities or provided by user
docstr_tok: ["Create","a","quantized","embedding","module","from","a","float","module","Args",":","mod","(","Module",")",":","a","float","module",",","either","produced","by","torch.ao.quantization","utilities","or","provided","by","user"]
code: def from_float(cls, mod):
      r"""Create a quantized embedding module from a float module
  
      Args:
          mod (Module): a float module, either produced by torch.ao.quantization
                        utilities or provided by user
      """
      if hasattr(mod, "weight_fake_quant"):
          assert type(mod) == torch.ao.nn.qat.Embedding, (
              "nnq."
              + cls.__name__
              + ".from_float "
              + "with fake quant only works for "
              + torch.ao.nn.qat.Embedding.__name__
          )
          weight_observer = mod.weight_fake_quant
          activation_post_process = mod.activation_post_process
      else:
          assert type(mod) == nn.Embedding, (
              "nnq."
              + cls.__name__
              + ".from_float only works for "
              + nn.Embedding.__name__
          )
          assert hasattr(
              mod, "qconfig"
          ), "Embedding input float module must have qconfig defined"
          from torch.ao.quantization import (
              float_qparams_weight_only_qconfig,
          )
  
          if mod.qconfig is not None and mod.qconfig.weight is not None:  # type: ignore[union-attr]
              weight_observer = mod.qconfig.weight()  # type: ignore[union-attr, operator]
          else:
              weight_observer = (
                  float_qparams_weight_only_qconfig.weight()
              )
  
      dtype = weight_observer.dtype
      is_float_qparams_qconfig = (
          weight_observer.qscheme
          == torch.per_channel_affine_float_qparams
      )
      assert (
          is_float_qparams_qconfig
      ), "Embedding quantization is only supported with float_qparams_weight_only_qconfig."
  
      assert (
          dtype == torch.quint8 or dtype == torch.quint4x2
      ), f"The only supported dtype for nnq.Embedding is torch.quint8 and torch.quint4x2, got {dtype}"
  
      # Run the observer to calculate qparams.
      weight_observer(mod.weight)
      qweight = _quantize_weight(mod.weight.float(), weight_observer)
  
      # Create quantized Embedding module and pass in the quantized weight
      qembedding = Embedding(mod.num_embeddings, mod.embedding_dim)
      qembedding.set_weight(qweight)
      return qembedding
  
imports: import torch
  import torch.nn
  from torch import Tensor
  from torch._jit_internal import Optional, List
  from .utils import _hide_packed_params_repr
  from .utils import _quantize_weight
label_desc: Use image node_id 8 for calling the Embedding obj's underlying member method code with example usage: obj.from_float(cls, mod) and returns: qembedding