class_docstr: Thin wrapper around PyTorch's Embedding op.
  
  :param config: Embedding config.
  :param embedding: pre-existing embedding Module.
  :param dtype: Torch data type for parameters.
code: def __init__(
      self,
      config: EmbeddingConfig,
      embedding: Optional[pt.nn.Embedding] = None,
      dtype: Optional[pt.dtype] = None,
  ) -> None:
      super().__init__()
      self.config = config
      if embedding is not None:
          self.embedding = embedding
      else:
          self.embedding = pt.nn.Embedding(
              self.config.vocab_size,
              self.config.num_embed,
              sparse=self.config.allow_sparse_grad,
              dtype=dtype,
          )
  
      self.num_factors = self.config.num_factors
      self.factor_embeds = pt.nn.ModuleList()
      self.factor_combinations = []  # type: List[str]
      if self.config.factor_configs is not None:
          for i, fc in enumerate(self.config.factor_configs, 1):
              if fc.share_embedding:
                  factor_embed = self.embedding
              else:
                  factor_embed = pt.nn.Embedding(
                      fc.vocab_size,
                      fc.num_embed,
                      sparse=self.config.allow_sparse_grad,
                      dtype=dtype,
                  )
              self.factor_embeds.append(factor_embed)
              self.factor_combinations.append(fc.combine)
  
      self.dropout = pt.nn.Dropout(p=self.config.dropout)
  
imports: from abc import abstractmethod
  from dataclasses import dataclass, field
  from typing import List, Tuple, Optional, Union
  import torch
  import sockeye.constants
  from .None import config
  from .None import layers
  from .None import transformer
label_desc: Use image node_id 1 to create a new Embedding object from inherited base classes: Encoder with example: obj = Embedding(config, embedding, dtype)