class_docstr: EmbeddingBagCollection represents a collection of pooled embeddings (EmbeddingBags).
  This EmbeddingBagCollection is quantized for lower precision. It relies on fbgemm quantized ops and provides
  table batching.
  
  It processes sparse data in the form of KeyedJaggedTensor
  with values of the form [F X B X L]
  F: features (keys)
  B: batch size
  L: Length of sparse features (jagged)
  
  and outputs a KeyedTensor with values of the form [B * (F * D)]
  where
  F: features (keys)
  D: each feature's (key's) embedding dimension
  B: batch size
  
  Args:
      table_name_to_quantized_weights (Dict[str, Tuple[Tensor, Tensor]]): map of tables to quantized weights
      embedding_configs (List[EmbeddingBagConfig]): list of embedding tables
      is_weighted: (bool): whether input KeyedJaggedTensor is weighted
      device: (Optional[torch.device]): default compute device
  
  Call Args:
      features: KeyedJaggedTensor,
  
  Returns:
      KeyedTensor
  
  Example::
  
      table_0 = EmbeddingBagConfig(
          name="t1", embedding_dim=3, num_embeddings=10, feature_names=["f1"]
      )
      table_1 = EmbeddingBagConfig(
          name="t2", embedding_dim=4, num_embeddings=10, feature_names=["f2"]
      )
      ebc = EmbeddingBagCollection(tables=[eb1_config, eb2_config])
  
      #        0       1        2  <-- batch
      # "f1"   [0,1] None    [2]
      # "f2"   [3]    [4]    [5,6,7]
      #  ^
      # feature
      features = KeyedJaggedTensor(
          keys=["f1", "f2"],
          values=torch.tensor([0, 1, 2, 3, 4, 5, 6, 7]),
          offsets=torch.tensor([0, 2, 2, 3, 4, 5, 8]),
      )
  
      ebc.qconfig = torch.quantization.QConfig(
          activation=torch.quantization.PlaceholderObserver.with_args(
              dtype=torch.qint8
          ),
          weight=torch.quantization.PlaceholderObserver.with_args(dtype=torch.qint8),
      )
  
      qebc = QuantEmbeddingBagCollection.from_float(ebc)
      quantized_embeddings = qebc(features)
class_docstr_tok: ["EmbeddingBagCollection","represents","a","collection","of","pooled","embeddings","(","EmbeddingBags",")",".","This","EmbeddingBagCollection","is","quantized","for","lower","precision",".","It","relies","on","fbgemm","quantized","ops","and","provides","table","batching",".","It","processes","sparse","data","in","the","form","of","KeyedJaggedTensor","with","values","of","the","form","[","F","X","B","X","L","]","F",":","features","(","keys",")","B",":","batch","size","L",":","Length","of","sparse","features","(","jagged",")","and","outputs","a","KeyedTensor","with","values","of","the","form","[","B","*","(","F","*","D",")","]","where","F",":","features","(","keys",")","D",":","each","feature","'s","(","key","'s",")","embedding","dimension","B",":","batch","size","Args",":","table_name_to_quantized_weights","(","Dict","[","str",",","Tuple","[","Tensor",",","Tensor","]","]",")",":","map","of","tables","to","quantized","weights","embedding_configs","(","List","[","EmbeddingBagConfig","]",")",":","list","of","embedding","tables","is_weighted",":","(","bool",")",":","whether","input","KeyedJaggedTensor","is","weighted","device",":","(","Optional","[","torch.device","]",")",":","default","compute","device","Call","Args",":","features",":","KeyedJaggedTensor",",","Returns",":","KeyedTensor","Example",":",":","table_0","=","EmbeddingBagConfig","(","name=","''","t1","''",",","embedding_dim=3",",","num_embeddings=10",",","feature_names=","[","``","f1","''","]",")","table_1","=","EmbeddingBagConfig","(","name=","''","t2","''",",","embedding_dim=4",",","num_embeddings=10",",","feature_names=","[","``","f2","''","]",")","ebc","=","EmbeddingBagCollection","(","tables=","[","eb1_config",",","eb2_config","]",")","#","0","1","2","<","--","batch","#","``","f1","''","[","0,1","]","None","[","2","]","#","``","f2","''","[","3","]","[","4","]","[","5,6,7","]","#","^","#","feature","features","=","KeyedJaggedTensor","(","keys=","[","``","f1","''",",","``","f2","''","]",",","values=torch.tensor","(","[","0",",","1",",","2",",","3",",","4",",","5",",","6",",","7","]",")",",","offsets=torch.tensor","(","[","0",",","2",",","2",",","3",",","4",",","5",",","8","]",")",",",")","ebc.qconfig","=","torch.quantization.QConfig","(","activation=torch.quantization.PlaceholderObserver.with_args","(","dtype=torch.qint8",")",",","weight=torch.quantization.PlaceholderObserver.with_args","(","dtype=torch.qint8",")",",",")","qebc","=","QuantEmbeddingBagCollection.from_float","(","ebc",")","quantized_embeddings","=","qebc","(","features",")"]
code: def from_float(
      cls, module: OriginalEmbeddingBagCollection
  ) -> "EmbeddingBagCollection":
      assert hasattr(
          module, "qconfig"
      ), "EmbeddingBagCollection input float module must have qconfig defined"
      embedding_bag_configs = copy.deepcopy(
          module.embedding_bag_configs()
      )
      _update_embedding_configs(
          cast(List[BaseEmbeddingConfig], embedding_bag_configs),
          module.qconfig,
      )
      pruning_dict: Dict[str, torch.Tensor] = getattr(
          module,
          MODULE_ATTR_EMB_CONFIG_NAME_TO_PRUNING_INDICES_REMAPPING_DICT,
          {},
      )
  
      for config in embedding_bag_configs:
          if config.name in pruning_dict:
              pruning_indices_remapping = pruning_dict[config.name]
              config.num_embeddings = pruned_num_embeddings(
                  pruning_indices_remapping
              )
              config.pruning_indices_remapping = (
                  pruning_indices_remapping
              )
  
      table_name_to_quantized_weights: Dict[
          str, Tuple[Tensor, Tensor]
      ] = {}
      device = quantize_state_dict(
          module,
          table_name_to_quantized_weights,
          {
              table.name: table.data_type
              for table in embedding_bag_configs
          },
          pruning_dict,
      )
      return cls(
          embedding_bag_configs,
          module.is_weighted(),
          device=device,
          output_dtype=module.qconfig.activation().dtype,
          table_name_to_quantized_weights=table_name_to_quantized_weights,
          register_tbes=getattr(
              module, MODULE_ATTR_REGISTER_TBES_BOOL, False
          ),
          quant_state_dict_split_scale_bias=getattr(
              module,
              MODULE_ATTR_QUANT_STATE_DICT_SPLIT_SCALE_BIAS,
              False,
          ),
          row_alignment=getattr(
              module,
              MODULE_ATTR_ROW_ALIGNMENT_INT,
              DEFAULT_ROW_ALIGNMENT,
          ),
      )
  
imports: import copy
  import itertools
  from collections import defaultdict
  from typing import Callable, cast, Dict, List, Optional, Tuple, Type, Union
  import torch
  import torch.nn
  from fbgemm_gpu.split_table_batched_embeddings_ops_inference import EmbeddingLocation, IntNBitTableBatchedEmbeddingBagsCodegen, PoolingMode
  from torch import Tensor
  from torchrec.distributed.utils import none_throws
  from torchrec.modules.embedding_configs import BaseEmbeddingConfig, DATA_TYPE_NUM_BITS, data_type_to_sparse_type, DataType, dtype_to_data_type, EmbeddingBagConfig, EmbeddingConfig, pooling_type_to_pooling_mode, PoolingType, QuantConfig
  from torchrec.modules.embedding_modules import EmbeddingBagCollection, EmbeddingBagCollectionInterface, EmbeddingCollection, EmbeddingCollectionInterface, get_embedding_names_by_table
  from torchrec.modules.feature_processor_ import FeatureProcessorsCollection
  from torchrec.modules.fp_embedding_modules import FeatureProcessedEmbeddingBagCollection
  from torchrec.sparse.jagged_tensor import JaggedTensor, KeyedJaggedTensor, KeyedTensor
  from torchrec.tensor_types import UInt2Tensor, UInt4Tensor
  from torchrec.types import ModuleNoCopyMixin
label_desc: Use image node_id 4 for calling the EmbeddingBagCollection obj's underlying member method code with example usage: obj.from_float(cls, module) and returns: cls