class_docstr: A simple lookup table that stores embeddings of a fixed dictionary and size.
  This module is often used to store word embeddings and retrieve them using indices.
  The input to the module is a list of indices, and the output is the corresponding
  word embeddings. This subclass differs from the standard PyTorch Embedding class by
  allowing additional vocabulary entries that will be mapped to the unknown token
  embedding.
  Args:
      num_embeddings (int): size of the dictionary of embeddings
      embedding_dim (int): the size of each embedding vector
      padding_idx (int): Pads the output with the embedding vector at :attr:`padding_idx`
                         (initialized to zeros) whenever it encounters the index.
      unk_idx (int): Maps all token indices that are greater than or equal to
                     num_embeddings to this index.
  Attributes:
      weight (Tensor): the learnable weights of the module of shape (num_embeddings, embedding_dim)
                       initialized from :math:`\mathcal{N}(0, 1)`
  Shape:
      - Input: :math:`(*)`, LongTensor of arbitrary shape containing the indices to extract
      - Output: :math:`(*, H)`, where `*` is the input shape and :math:`H=\text{embedding\_dim}`
  .. note::
      Keep in mind that only a limited number of optimizers support
      sparse gradients: currently it's :class:`optim.SGD` (`CUDA` and `CPU`),
      :class:`optim.SparseAdam` (`CUDA` and `CPU`) and :class:`optim.Adagrad` (`CPU`)
  .. note::
      With :attr:`padding_idx` set, the embedding vector at
      :attr:`padding_idx` is initialized to all zeros. However, note that this
      vector can be modified afterwards, e.g., using a customized
      initialization method, and thus changing the vector used to pad the
      output. The gradient for this vector from :class:`~torch.nn.Embedding`
      is always zero.
class_docstr_tok: ["A","simple","lookup","table","that","stores","embeddings","of","a","fixed","dictionary","and","size",".","This","module","is","often","used","to","store","word","embeddings","and","retrieve","them","using","indices",".","The","input","to","the","module","is","a","list","of","indices",",","and","the","output","is","the","corresponding","word","embeddings",".","This","subclass","differs","from","the","standard","PyTorch","Embedding","class","by","allowing","additional","vocabulary","entries","that","will","be","mapped","to","the","unknown","token","embedding",".","Args",":","num_embeddings","(","int",")",":","size","of","the","dictionary","of","embeddings","embedding_dim","(","int",")",":","the","size","of","each","embedding","vector","padding_idx","(","int",")",":","Pads","the","output","with","the","embedding","vector","at",":","attr",":","`","padding_idx","`","(","initialized","to","zeros",")","whenever","it","encounters","the","index",".","unk_idx","(","int",")",":","Maps","all","token","indices","that","are","greater","than","or","equal","to","num_embeddings","to","this","index",".","Attributes",":","weight","(","Tensor",")",":","the","learnable","weights","of","the","module","of","shape","(","num_embeddings",",","embedding_dim",")","initialized","from",":","math",":","`","\\mathcal","{","N","}","(","0",",","1",")","`","Shape",":","-","Input",":",":","math",":","`","(","*",")","`",",","LongTensor","of","arbitrary","shape","containing","the","indices","to","extract","-","Output",":",":","math",":","`","(","*",",","H",")","`",",","where","`","*","`","is","the","input","shape","and",":","math",":","`","H=\\text","{","embedding\\_dim","}","`","..","note",":",":","Keep","in","mind","that","only","a","limited","number","of","optimizers","support","sparse","gradients",":","currently","it","'s",":","class",":","`","optim.SGD","`","(","`","CUDA","`","and","`","CPU","`",")",",",":","class",":","`","optim.SparseAdam","`","(","`","CUDA","`","and","`","CPU","`",")","and",":","class",":","`","optim.Adagrad","`","(","`","CPU","`",")","..","note",":",":","With",":","attr",":","`","padding_idx","`","set",",","the","embedding","vector","at",":","attr",":","`","padding_idx","`","is","initialized","to","all","zeros",".","However",",","note","that","this","vector","can","be","modified","afterwards",",","e.g.",",","using","a","customized","initialization","method",",","and","thus","changing","the","vector","used","to","pad","the","output",".","The","gradient","for","this","vector","from",":","class",":","`","~torch.nn.Embedding","`","is","always","zero","."]
code: def forward(self, input):
      input = torch.where(
          input >= self.num_embeddings,
          torch.ones_like(input) * self.unk_idx,
          input,
      )
      return nn.functional.embedding(
          input,
          self.weight,
          self.padding_idx,
          self.max_norm,
          self.norm_type,
          self.scale_grad_by_freq,
          self.sparse,
      )
  
imports: import logging
  from typing import Any, Dict, Optional, List, Tuple
  import torch
  import torch.nn
  from fairseq import utils
  from fairseq.models import register_model, register_model_architecture
  from fairseq.models.transformer import DEFAULT_MAX_SOURCE_POSITIONS, DEFAULT_MAX_TARGET_POSITIONS, TransformerDecoder, TransformerEncoder, TransformerModel, base_architecture
  from torch import Tensor
label_desc: Use image node_id 2 for calling the Embedding obj's underlying member method code with example usage: obj.forward(input) and returns: nn