class_docstr: 词向量嵌入，支持输入多种方式初始化. 可以通过 ``self.num_embeddings`` 获取词表大小; ``self.embedding_dim`` 获取 ``embedding`` 的维度.
  
  Example::
  
      >>> import numpy as np
      >>> from fastNLP.embeddings.torch import Embedding
      >>> init_embed = (2000, 100)
      >>> embed = Embedding(init_embed)  # 随机初始化一个具有2000个词，每个词表示为100维的词向量
      >>> init_embed = np.zeros((2000, 100))
      >>> embed = Embedding(init_embed)  # 使用numpy.ndarray的值作为初始化值初始化一个Embedding
  
  :param init_embed: 支持传入 Embedding 的大小。支持以下类型：
  
          1. 传入 tuple(int, int)，第一个 int 为 ``vocab_size``, 第二个 int  ``为embed_dim``；
          2. 传入 :class:`Tensor`, :class:`Embedding`, :class:`numpy.ndarray` 等则直接使用该值初始化 Embedding；
  
  :param word_dropout: 按照一定概率随机将 word 设置为 ``unk_index`` ，这样可以使得 ``<UNK>`` 这个 token 得到足够的训练，
      且会对网络有一定的 regularize 作用。设置该值时，必须同时设置 ``unk_index``。
  :param dropout: 对 Embedding 的输出的 dropout。
  :param unk_index: drop word 时替换为的 index。**fastNLP** 的 :class:`fastNLP.Vocabulary`` 的 ``unk_index`` 默认为 1。
class_docstr_tok: ["\u8bcd\u5411\u91cf\u5d4c\u5165\uff0c\u652f\u6301\u8f93\u5165\u591a\u79cd\u65b9\u5f0f\u521d\u59cb\u5316",".","\u53ef\u4ee5\u901a\u8fc7","``","self.num_embeddings","``","\u83b7\u53d6\u8bcd\u8868\u5927\u5c0f",";","``","self.embedding_dim","``","\u83b7\u53d6","``","embedding","``","\u7684\u7ef4\u5ea6",".","Example",":",":",">",">",">","import","numpy","as","np",">",">",">","from","fastNLP.embeddings.torch","import","Embedding",">",">",">","init_embed","=","(","2000",",","100",")",">",">",">","embed","=","Embedding","(","init_embed",")","#","\u968f\u673a\u521d\u59cb\u5316\u4e00\u4e2a\u5177\u67092000\u4e2a\u8bcd\uff0c\u6bcf\u4e2a\u8bcd\u8868\u793a\u4e3a100\u7ef4\u7684\u8bcd\u5411\u91cf",">",">",">","init_embed","=","np.zeros","(","(","2000",",","100",")",")",">",">",">","embed","=","Embedding","(","init_embed",")","#","\u4f7f\u7528numpy.ndarray\u7684\u503c\u4f5c\u4e3a\u521d\u59cb\u5316\u503c\u521d\u59cb\u5316\u4e00\u4e2aEmbedding",":","param","init_embed",":","\u652f\u6301\u4f20\u5165","Embedding","\u7684\u5927\u5c0f\u3002\u652f\u6301\u4ee5\u4e0b\u7c7b\u578b\uff1a","1",".","\u4f20\u5165","tuple","(","int",",","int",")","\uff0c\u7b2c\u4e00\u4e2a","int","\u4e3a","``","vocab_size","``",",","\u7b2c\u4e8c\u4e2a","int","``","\u4e3aembed_dim","``","\uff1b","2",".","\u4f20\u5165",":","class",":","`","Tensor","`",",",":","class",":","`","Embedding","`",",",":","class",":","`","numpy.ndarray","`","\u7b49\u5219\u76f4\u63a5\u4f7f\u7528\u8be5\u503c\u521d\u59cb\u5316","Embedding\uff1b",":","param","word_dropout",":","\u6309\u7167\u4e00\u5b9a\u6982\u7387\u968f\u673a\u5c06","word","\u8bbe\u7f6e\u4e3a","``","unk_index","``","\uff0c\u8fd9\u6837\u53ef\u4ee5\u4f7f\u5f97","``","<","UNK",">","``","\u8fd9\u4e2a","token","\u5f97\u5230\u8db3\u591f\u7684\u8bad\u7ec3\uff0c","\u4e14\u4f1a\u5bf9\u7f51\u7edc\u6709\u4e00\u5b9a\u7684","regularize","\u4f5c\u7528\u3002\u8bbe\u7f6e\u8be5\u503c\u65f6\uff0c\u5fc5\u987b\u540c\u65f6\u8bbe\u7f6e","``","unk_index","``","\u3002",":","param","dropout",":","\u5bf9","Embedding","\u7684\u8f93\u51fa\u7684","dropout\u3002",":","param","unk_index",":","drop","word","\u65f6\u66ff\u6362\u4e3a\u7684","index\u3002","*","*","fastNLP","*","*","\u7684",":","class",":","`","fastNLP.Vocabulary","``","\u7684","``","unk_index","``","\u9ed8\u8ba4\u4e3a","1\u3002"]
code: def size(self):
      if isinstance(self.embed, TokenEmbedding):
          return self.embed.size
      else:
          return self.embed.weight.size()
  
imports: from abc import abstractmethod
  from typing import Union, Tuple
  from ...envs.imports import _NEED_IMPORT_TORCH
  import numpy
  from .utils import get_embeddings
label_desc: Use image node_id 9 for calling the Embedding obj's underlying member method code with example usage: obj.size() and returns: self, self