class_docstr: Module for dictionary feature embeddings for tokens. Dictionary features are
  also known as gazetteer features. These are per token discrete features that
  the module learns embeddings for.
  Example: For the utterance *Order coffee from Starbucks*, the dictionary
  features could be
  ::
  
      [
          {"tokenIdx": 1, "features": {"drink/beverage": 0.8, "music/song": 0.2}},
          {"tokenIdx": 3, "features": {"store/coffee_shop": 1.0}}
      ]
  
  ::
  Thus, for a given token there can be more than one dictionary features each
  of which has a confidence score. The final embedding for a token is the
  weighted average of the dictionary embeddings followed by a pooling operation
  such that the module produces an embedding vector per token.
  
  Args:
      num_embeddings (int): Total number of dictionary features (vocabulary size).
      embed_dim (int): Size of embedding vector.
      pooling_type (PoolingType): Type of pooling for combining the dictionary
          feature embeddings.
  
  Attributes:
      pooling_type (PoolingType): Type of pooling for combining the dictionary
          feature embeddings.
class_docstr_tok: ["Module","for","dictionary","feature","embeddings","for","tokens",".","Dictionary","features","are","also","known","as","gazetteer","features",".","These","are","per","token","discrete","features","that","the","module","learns","embeddings","for",".","Example",":","For","the","utterance","*","Order","coffee","from","Starbucks","*",",","the","dictionary","features","could","be",":",":","[","{","``","tokenIdx","''",":","1",",","``","features","''",":","{","``","drink\/beverage","''",":","0.8",",","``","music\/song","''",":","0.2","}","}",",","{","``","tokenIdx","''",":","3",",","``","features","''",":","{","``","store\/coffee_shop","''",":","1.0","}","}","]",":",":","Thus",",","for","a","given","token","there","can","be","more","than","one","dictionary","features","each","of","which","has","a","confidence","score",".","The","final","embedding","for","a","token","is","the","weighted","average","of","the","dictionary","embeddings","followed","by","a","pooling","operation","such","that","the","module","produces","an","embedding","vector","per","token",".","Args",":","num_embeddings","(","int",")",":","Total","number","of","dictionary","features","(","vocabulary","size",")",".","embed_dim","(","int",")",":","Size","of","embedding","vector",".","pooling_type","(","PoolingType",")",":","Type","of","pooling","for","combining","the","dictionary","feature","embeddings",".","Attributes",":","pooling_type","(","PoolingType",")",":","Type","of","pooling","for","combining","the","dictionary","feature","embeddings","."]
docstr: Factory method to construct an instance of DictEmbedding from
  the module's config object and the field's metadata object.
  
  Args:
      config (DictFeatConfig): Configuration object specifying all the
      parameters of DictEmbedding.
      metadata (FieldMeta): Object containing this field's metadata.
  
  Returns:
      type: An instance of DictEmbedding.
docstr_tok: ["Factory","method","to","construct","an","instance","of","DictEmbedding","from","the","module","'s","config","object","and","the","field","'s","metadata","object",".","Args",":","config","(","DictFeatConfig",")",":","Configuration","object","specifying","all","the","parameters","of","DictEmbedding",".","metadata","(","FieldMeta",")",":","Object","containing","this","field","'s","metadata",".","Returns",":","type",":","An","instance","of","DictEmbedding","."]
code: def from_config(
      cls,
      config: DictFeatConfig,
      metadata: Optional[FieldMeta] = None,
      labels: Optional[Vocabulary] = None,
      tensorizer: Optional[Tensorizer] = None,
  ):
      """Factory method to construct an instance of DictEmbedding from
      the module's config object and the field's metadata object.
  
      Args:
          config (DictFeatConfig): Configuration object specifying all the
          parameters of DictEmbedding.
          metadata (FieldMeta): Object containing this field's metadata.
  
      Returns:
          type: An instance of DictEmbedding.
  
      """
      # TODO: clean this up once fully migrated to new data handler design
      vocab_size = (
          len(tensorizer.vocab)
          if tensorizer is not None
          else len(labels)
          if labels is not None
          else metadata.vocab_size
      )
      tensorizer_vocab_exists = tensorizer and tensorizer.vocab
      pad_index = (
          tensorizer.vocab.get_pad_index()
          if tensorizer_vocab_exists
          else PAD_INDEX
      )
      unk_index = (
          tensorizer.vocab.get_unk_index()
          if tensorizer_vocab_exists
          else UNK_INDEX
      )
      return cls(
          num_embeddings=vocab_size,
          embed_dim=config.embed_dim,
          pooling_type=config.pooling,
          pad_index=pad_index,
          unk_index=unk_index,
          mobile=config.mobile,
          use_weights=config.use_weights,
      )
  
file_path: pytext/pytext/models/embeddings/dict_embedding.py
imports: from typing import Optional
  import torch
  import torch.nn
  import torch.onnx.operators
  from pytext.config.field_config import DictFeatConfig
  from pytext.config.module_config import PoolingType
  from pytext.data.tensorizers import Tensorizer
  from pytext.data.utils import PAD_INDEX, UNK_INDEX, Vocabulary
  from pytext.fields import FieldMeta
  from pytext.utils.usage import log_class_usage
  from .embedding_base import EmbeddingBase
label_desc: Use image node_id 1 for calling the DictEmbedding obj's underlying member method code with example usage: obj.from_config(cls, config, metadata, labels, tensorizer) and returns: cls