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: `torch.where` is not supported for mobile ONNX, this hack allows a mobile
  exported version of `torch.where` which is computationally more expensive
docstr_tok: ["`","torch.where","`","is","not","supported","for","mobile","ONNX",",","this","hack","allows","a","mobile","exported","version","of","`","torch.where","`","which","is","computationally","more","expensive"]
code: def find_and_replace(
      self, tensor: torch.Tensor, find_val: int, replace_val: int
  ) -> torch.Tensor:
      """
      `torch.where` is not supported for mobile ONNX, this hack allows a mobile
      exported version of `torch.where` which is computationally more expensive
      """
      if self.mobile:
          mask = torch.eq(tensor, find_val)
          return tensor * (1 - mask.long()) + mask * replace_val
      else:
          return torch.where(
              tensor == find_val,
              torch.full_like(tensor, replace_val),
              tensor,
          )
  
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 3 for calling the DictEmbedding obj's underlying member method code with example usage: obj.find_and_replace(tensor, find_val, replace_val) and returns: unknown, torch