class_docstr: ``StaticEmbedding`` 组件。给定预训练 embedding 的名称或路径，根据 ``vocab`` 从 embedding 中抽取相应的数据（只会将出现在 ``vocab`` 中的词抽取出来，
  如果没有找到，则会随机初始化一个值；但如果该 word 是被标记为 ``no_create_entry`` 的话，则不会单独创建一个值，而是被指向 ``<UNK>`` 的 index）。
  当前支持自动下载的预训练 vector 有:
  
      - ``en`` -- 实际为 ``en-glove-840b-300d`` （常用）
      - ``en-glove-6b-50d`` -- **glove** 官方的 50d 向量
      - ``en-glove-6b-100d`` -- **glove** 官方的 100d 向量
      - ``en-glove-6b-200d`` -- **glove** 官方的 200d 向量
      - ``en-glove-6b-300d`` -- **glove** 官方的 300d 向量
      - ``en-glove-42b-300d`` -- **glove** 官方使用 42B 数据训练版本
      - ``en-glove-840b-300d``
      - ``en-glove-twitter-27b-25d``
      - ``en-glove-twitter-27b-50d``
      - ``en-glove-twitter-27b-100d``
      - ``en-glove-twitter-27b-200d``
      - ``en-word2vec-300d`` -- **word2vec** 官方发布的 300d 向量
      - ``en-fasttext-crawl`` -- **fasttext** 官方发布的 300d 英文预训练
      - ``cn-char-fastnlp-100d`` -- **fastNLP** 训练的 100d 的 character embedding
      - ``cn-bi-fastnlp-100d`` -- **fastNLP** 训练的 100d 的 bigram embedding
      - ``cn-tri-fastnlp-100d`` -- **fastNLP** 训练的 100d 的 trigram embedding
      - ``cn-fasttext`` -- **fasttext** 官方发布的 300d 中文预训练 embedding
  
  Example::
      
      >>> from fastNLP import Vocabulary
      >>> from fastNLP.embeddings.torch import StaticEmbedding
      >>> vocab = Vocabulary().add_word_lst("The whether is good .".split())
      >>> embed = StaticEmbedding(vocab, model_dir_or_name='en-glove-50d')
  
      >>> vocab = Vocabulary().add_word_lst(["The", 'the', "THE"])
      >>> embed = StaticEmbedding(vocab, model_dir_or_name="en-glove-50d", lower=True)
      >>> # "the", "The", "THE"它们共用一个vector，且将使用"the"在预训练词表中寻找它们的初始化表示。
  
      >>> vocab = Vocabulary().add_word_lst(["The", "the", "THE"])
      >>> embed = StaticEmbedding(vocab, model_dir_or_name=None, embedding_dim=5, lower=True)
      >>> words = torch.LongTensor([[vocab.to_index(word) for word in ["The", "the", "THE"]]])
      >>> embed(words)
      >>> tensor([[[ 0.5773,  0.7251, -0.3104,  0.0777,  0.4849],
                   [ 0.5773,  0.7251, -0.3104,  0.0777,  0.4849],
                   [ 0.5773,  0.7251, -0.3104,  0.0777,  0.4849]]],
                 grad_fn=<EmbeddingBackward>)  # 每种word的输出是一致的。
      
  :param vocab: 词表。``StaticEmbedding`` 只会加载包含在词表中的词的词向量，在预训练向量中没找到的使用随机初始化
  :param model_dir_or_name: 可以有两种方式调用预训练好的 :class:`StaticEmbedding` ：
  
          1. 传入 embedding 文件夹（文件夹下应该只有一个以 **.txt** 作为后缀的文件）或文件路径；
          2. 传入 embedding 的名称，第二种情况将自动查看缓存中是否存在该模型，没有的话将自动下载;
          3. 如果输入为 ``None`` 则使用 ``embedding_dim`` 的维度随机初始化一个 embedding；
  :param embedding_dim: 随机初始化的 embedding 的维度，当该值为大于 0 的值时，将忽略 ``model_dir_or_name`` 。
  :param requires_grad: 是否需要梯度。
  :param init_method: 如何初始化没有找到的值。可以使用 :mod:`torch.nn.init` 中的各种方法，传入的方法应该接受一个 tensor，并
      inplace 地修改其值。
  :param lower: 是否将 ``vocab`` 中的词语小写后再和预训练的词表进行匹配。如果您的词表中包含大写的词语，或者就是需要单独
      为大写的词语开辟一个 vector 表示，则将 ``lower`` 设置为 ``False``。
  :param dropout: 以多大的概率对 embedding 的表示进行 Dropout。0.1 即随机将 10% 的值置为 0。
  :param word_dropout: 按照一定概率随机将 word 设置为 ``unk_index`` ，这样可以使得 ``<UNK>`` 这个 token 得到足够的训练，
      且会对网络有一定的 regularize 作用。
  :param normalize: 是否对 vector 进行 ``normalize`` ，使得每个 vector 的 norm 为 1。
  :param min_freq: Vocabulary 词频数小于这个数量的 word 将被指向 ``<UNK>``。
  :kwargs:
      * *only_train_min_freq* (*bool*) -- 仅对 train 中的词语使用 ``min_freq`` 筛选
      * *only_norm_found_vector* (*bool*) -- 默认为 ``False``，是否仅对在预训练中找到的词语使用 ``normalize``
      * *only_use_pretrain_word* (*bool*) -- 默认为 ``False``，仅使用出现在 pretrain 词表中的词，如果该词没有在预训练的词表中出现
        则为 ``<UNK>`` 。如果 embedding 不需要更新建议设置为 ``True`` 。
class_docstr_tok: ["``","StaticEmbedding","``","\u7ec4\u4ef6\u3002\u7ed9\u5b9a\u9884\u8bad\u7ec3","embedding","\u7684\u540d\u79f0\u6216\u8def\u5f84\uff0c\u6839\u636e","``","vocab","``","\u4ece","embedding","\u4e2d\u62bd\u53d6\u76f8\u5e94\u7684\u6570\u636e\uff08\u53ea\u4f1a\u5c06\u51fa\u73b0\u5728","``","vocab","``","\u4e2d\u7684\u8bcd\u62bd\u53d6\u51fa\u6765\uff0c","\u5982\u679c\u6ca1\u6709\u627e\u5230\uff0c\u5219\u4f1a\u968f\u673a\u521d\u59cb\u5316\u4e00\u4e2a\u503c\uff1b\u4f46\u5982\u679c\u8be5","word","\u662f\u88ab\u6807\u8bb0\u4e3a","``","no_create_entry","``","\u7684\u8bdd\uff0c\u5219\u4e0d\u4f1a\u5355\u72ec\u521b\u5efa\u4e00\u4e2a\u503c\uff0c\u800c\u662f\u88ab\u6307\u5411","``","<","UNK",">","``","\u7684","index\uff09\u3002","\u5f53\u524d\u652f\u6301\u81ea\u52a8\u4e0b\u8f7d\u7684\u9884\u8bad\u7ec3","vector","\u6709",":","-","``","en","``","--","\u5b9e\u9645\u4e3a","``","en-glove-840b-300d","``","\uff08\u5e38\u7528\uff09","-","``","en-glove-6b-50d","``","--","*","*","glove","*","*","\u5b98\u65b9\u7684","50d","\u5411\u91cf","-","``","en-glove-6b-100d","``","--","*","*","glove","*","*","\u5b98\u65b9\u7684","100d","\u5411\u91cf","-","``","en-glove-6b-200d","``","--","*","*","glove","*","*","\u5b98\u65b9\u7684","200d","\u5411\u91cf","-","``","en-glove-6b-300d","``","--","*","*","glove","*","*","\u5b98\u65b9\u7684","300d","\u5411\u91cf","-","``","en-glove-42b-300d","``","--","*","*","glove","*","*","\u5b98\u65b9\u4f7f\u7528","42B","\u6570\u636e\u8bad\u7ec3\u7248\u672c","-","``","en-glove-840b-300d","``","-","``","en-glove-twitter-27b-25d","``","-","``","en-glove-twitter-27b-50d","``","-","``","en-glove-twitter-27b-100d","``","-","``","en-glove-twitter-27b-200d","``","-","``","en-word2vec-300d","``","--","*","*","word2vec","*","*","\u5b98\u65b9\u53d1\u5e03\u7684","300d","\u5411\u91cf","-","``","en-fasttext-crawl","``","--","*","*","fasttext","*","*","\u5b98\u65b9\u53d1\u5e03\u7684","300d","\u82f1\u6587\u9884\u8bad\u7ec3","-","``","cn-char-fastnlp-100d","``","--","*","*","fastNLP","*","*","\u8bad\u7ec3\u7684","100d","\u7684","character","embedding","-","``","cn-bi-fastnlp-100d","``","--","*","*","fastNLP","*","*","\u8bad\u7ec3\u7684","100d","\u7684","bigram","embedding","-","``","cn-tri-fastnlp-100d","``","--","*","*","fastNLP","*","*","\u8bad\u7ec3\u7684","100d","\u7684","trigram","embedding","-","``","cn-fasttext","``","--","*","*","fasttext","*","*","\u5b98\u65b9\u53d1\u5e03\u7684","300d","\u4e2d\u6587\u9884\u8bad\u7ec3","embedding","Example",":",":",">",">",">","from","fastNLP","import","Vocabulary",">",">",">","from","fastNLP.embeddings.torch","import","StaticEmbedding",">",">",">","vocab","=","Vocabulary","(",")",".add_word_lst","(","``","The","whether","is","good",".","``",".split","(",")",")",">",">",">","embed","=","StaticEmbedding","(","vocab",",","model_dir_or_name='en-glove-50d","'",")",">",">",">","vocab","=","Vocabulary","(",")",".add_word_lst","(","[","``","The","''",",","'the","'",",","``","THE","''","]",")",">",">",">","embed","=","StaticEmbedding","(","vocab",",","model_dir_or_name=","''","en-glove-50d","''",",","lower=True",")",">",">",">","#","``","the","''",",","``","The","''",",","``","THE","''","\u5b83\u4eec\u5171\u7528\u4e00\u4e2avector\uff0c\u4e14\u5c06\u4f7f\u7528","''","the","''","\u5728\u9884\u8bad\u7ec3\u8bcd\u8868\u4e2d\u5bfb\u627e\u5b83\u4eec\u7684\u521d\u59cb\u5316\u8868\u793a\u3002",">",">",">","vocab","=","Vocabulary","(",")",".add_word_lst","(","[","``","The","''",",","``","the","''",",","``","THE","''","]",")",">",">",">","embed","=","StaticEmbedding","(","vocab",",","model_dir_or_name=None",",","embedding_dim=5",",","lower=True",")",">",">",">","words","=","torch.LongTensor","(","[","[","vocab.to_index","(","word",")","for","word","in","[","``","The","''",",","``","the","''",",","``","THE","''","]","]","]",")",">",">",">","embed","(","words",")",">",">",">","tensor","(","[","[","[","0.5773",",","0.7251",",","-0.3104",",","0.0777",",","0.4849","]",",","[","0.5773",",","0.7251",",","-0.3104",",","0.0777",",","0.4849","]",",","[","0.5773",",","0.7251",",","-0.3104",",","0.0777",",","0.4849","]","]","]",",","grad_fn=","<","EmbeddingBackward",">",")","#","\u6bcf\u79cdword\u7684\u8f93\u51fa\u662f\u4e00\u81f4\u7684\u3002",":","param","vocab",":","\u8bcd\u8868\u3002","``","StaticEmbedding","``","\u53ea\u4f1a\u52a0\u8f7d\u5305\u542b\u5728\u8bcd\u8868\u4e2d\u7684\u8bcd\u7684\u8bcd\u5411\u91cf\uff0c\u5728\u9884\u8bad\u7ec3\u5411\u91cf\u4e2d\u6ca1\u627e\u5230\u7684\u4f7f\u7528\u968f\u673a\u521d\u59cb\u5316",":","param","model_dir_or_name",":","\u53ef\u4ee5\u6709\u4e24\u79cd\u65b9\u5f0f\u8c03\u7528\u9884\u8bad\u7ec3\u597d\u7684",":","class",":","`","StaticEmbedding","`","\uff1a","1",".","\u4f20\u5165","embedding","\u6587\u4ef6\u5939\uff08\u6587\u4ef6\u5939\u4e0b\u5e94\u8be5\u53ea\u6709\u4e00\u4e2a\u4ee5","*","*",".txt","*","*","\u4f5c\u4e3a\u540e\u7f00\u7684\u6587\u4ef6\uff09\u6216\u6587\u4ef6\u8def\u5f84\uff1b","2",".","\u4f20\u5165","embedding","\u7684\u540d\u79f0\uff0c\u7b2c\u4e8c\u79cd\u60c5\u51b5\u5c06\u81ea\u52a8\u67e5\u770b\u7f13\u5b58\u4e2d\u662f\u5426\u5b58\u5728\u8be5\u6a21\u578b\uff0c\u6ca1\u6709\u7684\u8bdd\u5c06\u81ea\u52a8\u4e0b\u8f7d",";","3",".","\u5982\u679c\u8f93\u5165\u4e3a","``","None","``","\u5219\u4f7f\u7528","``","embedding_dim","``","\u7684\u7ef4\u5ea6\u968f\u673a\u521d\u59cb\u5316\u4e00\u4e2a","embedding\uff1b",":","param","embedding_dim",":","\u968f\u673a\u521d\u59cb\u5316\u7684","embedding","\u7684\u7ef4\u5ea6\uff0c\u5f53\u8be5\u503c\u4e3a\u5927\u4e8e","0","\u7684\u503c\u65f6\uff0c\u5c06\u5ffd\u7565","``","model_dir_or_name","``","\u3002",":","param","requires_grad",":","\u662f\u5426\u9700\u8981\u68af\u5ea6\u3002",":","param","init_method",":","\u5982\u4f55\u521d\u59cb\u5316\u6ca1\u6709\u627e\u5230\u7684\u503c\u3002\u53ef\u4ee5\u4f7f\u7528",":","mod",":","`","torch.nn.init","`","\u4e2d\u7684\u5404\u79cd\u65b9\u6cd5\uff0c\u4f20\u5165\u7684\u65b9\u6cd5\u5e94\u8be5\u63a5\u53d7\u4e00\u4e2a","tensor\uff0c\u5e76","inplace","\u5730\u4fee\u6539\u5176\u503c\u3002",":","param","lower",":","\u662f\u5426\u5c06","``","vocab","``","\u4e2d\u7684\u8bcd\u8bed\u5c0f\u5199\u540e\u518d\u548c\u9884\u8bad\u7ec3\u7684\u8bcd\u8868\u8fdb\u884c\u5339\u914d\u3002\u5982\u679c\u60a8\u7684\u8bcd\u8868\u4e2d\u5305\u542b\u5927\u5199\u7684\u8bcd\u8bed\uff0c\u6216\u8005\u5c31\u662f\u9700\u8981\u5355\u72ec","\u4e3a\u5927\u5199\u7684\u8bcd\u8bed\u5f00\u8f9f\u4e00\u4e2a","vector","\u8868\u793a\uff0c\u5219\u5c06","``","lower","``","\u8bbe\u7f6e\u4e3a","``","False","``","\u3002",":","param","dropout",":","\u4ee5\u591a\u5927\u7684\u6982\u7387\u5bf9","embedding","\u7684\u8868\u793a\u8fdb\u884c","Dropout\u30020.1","\u5373\u968f\u673a\u5c06","10","%","\u7684\u503c\u7f6e\u4e3a","0\u3002",":","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",":","param","normalize",":","\u662f\u5426\u5bf9","vector","\u8fdb\u884c","``","normalize","``","\uff0c\u4f7f\u5f97\u6bcf\u4e2a","vector","\u7684","norm","\u4e3a","1\u3002",":","param","min_freq",":","Vocabulary","\u8bcd\u9891\u6570\u5c0f\u4e8e\u8fd9\u4e2a\u6570\u91cf\u7684","word","\u5c06\u88ab\u6307\u5411","``","<","UNK",">","``","\u3002",":","kwargs",":","*","*","only_train_min_freq","*","(","*","bool","*",")","--","\u4ec5\u5bf9","train","\u4e2d\u7684\u8bcd\u8bed\u4f7f\u7528","``","min_freq","``","\u7b5b\u9009","*","*","only_norm_found_vector","*","(","*","bool","*",")","--","\u9ed8\u8ba4\u4e3a","``","False","``","\uff0c\u662f\u5426\u4ec5\u5bf9\u5728\u9884\u8bad\u7ec3\u4e2d\u627e\u5230\u7684\u8bcd\u8bed\u4f7f\u7528","``","normalize","``","*","*","only_use_pretrain_word","*","(","*","bool","*",")","--","\u9ed8\u8ba4\u4e3a","``","False","``","\uff0c\u4ec5\u4f7f\u7528\u51fa\u73b0\u5728","pretrain","\u8bcd\u8868\u4e2d\u7684\u8bcd\uff0c\u5982\u679c\u8be5\u8bcd\u6ca1\u6709\u5728\u9884\u8bad\u7ec3\u7684\u8bcd\u8868\u4e2d\u51fa\u73b0","\u5219\u4e3a","``","<","UNK",">","``","\u3002\u5982\u679c","embedding","\u4e0d\u9700\u8981\u66f4\u65b0\u5efa\u8bae\u8bbe\u7f6e\u4e3a","``","True","``","\u3002"]
code: def __init__(
      self,
      vocab: Vocabulary,
      model_dir_or_name: Union[str, None] = "en",
      embedding_dim=-1,
      requires_grad: bool = True,
      init_method: Callable = None,
      lower=False,
      dropout=0,
      word_dropout=0,
      normalize=False,
      min_freq=1,
      **kwargs,
  ):
      super(StaticEmbedding, self).__init__(
          vocab, word_dropout=word_dropout, dropout=dropout
      )
      if embedding_dim > 0:
          if model_dir_or_name:
              logger.info(
                  f"StaticEmbedding will ignore `model_dir_or_name`, and randomly initialize embedding with"
                  f" dimension {embedding_dim}. If you want to use pre-trained embedding, "
                  f"set `embedding_dim` to 0."
              )
          model_dir_or_name = None
  
      # 得到cache_path
      if model_dir_or_name is None:
          assert (
              embedding_dim >= 1
          ), "The dimension of embedding should be larger than 1."
          embedding_dim = int(embedding_dim)
          model_path = None
      elif model_dir_or_name.lower() in PRETRAIN_STATIC_FILES:
          model_url = _get_embedding_url(
              "static", model_dir_or_name.lower()
          )
          model_path = cached_path(model_url, name="embedding")
          # 检查是否存在
      elif os.path.isfile(
          os.path.abspath(os.path.expanduser(model_dir_or_name))
      ):
          model_path = os.path.abspath(
              os.path.expanduser(model_dir_or_name)
          )
      elif os.path.isdir(
          os.path.abspath(os.path.expanduser(model_dir_or_name))
      ):
          model_path = _get_file_name_base_on_postfix(
              os.path.abspath(os.path.expanduser(model_dir_or_name)),
              ".txt",
          )
      else:
          raise ValueError(f"Cannot recognize {model_dir_or_name}.")
  
      kwargs["min_freq"] = min_freq
      kwargs["lower"] = lower
      # 根据min_freq缩小vocab
      truncate_vocab = (vocab.min_freq is None and min_freq > 1) or (
          vocab.min_freq and vocab.min_freq < min_freq
      )
      if truncate_vocab:
          truncated_vocab = deepcopy(vocab)
          truncated_vocab.min_freq = min_freq
          truncated_vocab.word2idx = None
          if lower:  # 如果有lower，将大小写的的freq需要同时考虑到
              lowered_word_count = defaultdict(int)
              for word, count in truncated_vocab.word_count.items():
                  lowered_word_count[word.lower()] += count
              for word in truncated_vocab.word_count.keys():
                  word_count = truncated_vocab.word_count[word]
                  if (
                      lowered_word_count[word.lower()] >= min_freq
                      and word_count < min_freq
                  ):
                      truncated_vocab.add_word_lst(
                          [word] * (min_freq - word_count),
                          no_create_entry=truncated_vocab._is_word_no_create_entry(
                              word
                          ),
                      )
  
          # 只限制在train里面的词语使用min_freq筛选
          if (
              kwargs.get("only_train_min_freq", False)
              and model_dir_or_name is not None
          ):
              for word in truncated_vocab.word_count.keys():
                  if (
                      truncated_vocab._is_word_no_create_entry(word)
                      and truncated_vocab.word_count[word] < min_freq
                  ):
                      truncated_vocab.add_word_lst(
                          [word]
                          * (
                              min_freq
                              - truncated_vocab.word_count[word]
                          ),
                          no_create_entry=True,
                      )
          truncated_vocab.build_vocab()
          truncated_words_to_words = torch.arange(len(vocab)).long()
          for word, index in vocab:
              truncated_words_to_words[
                  index
              ] = truncated_vocab.to_index(word)
          logger.info(
              f"{len(vocab) - len(truncated_vocab)} words have frequency less than {min_freq}."
          )
          vocab = truncated_vocab
  
      self.only_use_pretrain_word = kwargs.get(
          "only_use_pretrain_word", False
      )
      self.only_norm_found_vector = kwargs.get(
          "only_norm_found_vector", False
      )
      # 读取embedding
      if lower:
          lowered_vocab = Vocabulary(
              padding=vocab.padding, unknown=vocab.unknown
          )
          for word, index in vocab:
              if vocab._is_word_no_create_entry(word):
                  lowered_vocab.add_word(
                      word.lower(), no_create_entry=True
                  )
              else:
                  lowered_vocab.add_word(word.lower())  # 先加入需要创建entry的
          logger.info(
              f"All word in the vocab have been lowered. There are {len(vocab)} words, {len(lowered_vocab)} "
              f"unique lowered words."
          )
          if model_path:
              embedding = self._load_with_vocab(
                  model_path,
                  vocab=lowered_vocab,
                  init_method=init_method,
              )
          else:
              embedding = self._randomly_init_embed(
                  len(lowered_vocab), embedding_dim, init_method
              )
              self.register_buffer(
                  "words_to_words", torch.arange(len(vocab)).long()
              )
          if lowered_vocab.unknown:
              unknown_idx = lowered_vocab.unknown_idx
          else:
              unknown_idx = embedding.size(0) - 1  # 否则是最后一个为unknow
              self.register_buffer(
                  "words_to_words", torch.arange(len(vocab)).long()
              )
          words_to_words = torch.full(
              (len(vocab),), fill_value=unknown_idx, dtype=torch.long
          ).long()
          for word, index in vocab:
              if word not in lowered_vocab:
                  word = word.lower()
                  if (
                      word not in lowered_vocab
                      and lowered_vocab._is_word_no_create_entry(word)
                  ):
                      continue  # 如果不需要创建entry,已经默认unknown了
              words_to_words[index] = self.words_to_words[
                  lowered_vocab.to_index(word)
              ]
          self.register_buffer("words_to_words", words_to_words)
          self._word_unk_index = (
              lowered_vocab.unknown_idx
          )  # 替换一下unknown的index
      else:
          if model_path:
              embedding = self._load_with_vocab(
                  model_path, vocab=vocab, init_method=init_method
              )
          else:
              embedding = self._randomly_init_embed(
                  len(vocab), embedding_dim, init_method
              )
              self.register_buffer(
                  "words_to_words", torch.arange(len(vocab)).long()
              )
      if not self.only_norm_found_vector and normalize:
          embedding /= (
              torch.norm(embedding, dim=1, keepdim=True) + 1e-12
          )
  
      if truncate_vocab:
          for i in range(len(truncated_words_to_words)):
              index_in_truncated_vocab = truncated_words_to_words[i]
              truncated_words_to_words[i] = self.words_to_words[
                  index_in_truncated_vocab
              ]
          del self.words_to_words
          self.register_buffer(
              "words_to_words", truncated_words_to_words
          )
      self.embedding = nn.Embedding(
          num_embeddings=embedding.shape[0],
          embedding_dim=embedding.shape[1],
          padding_idx=vocab.padding_idx,
          max_norm=None,
          norm_type=2,
          scale_grad_by_freq=False,
          sparse=False,
          _weight=embedding,
      )
      self._embed_size = self.embedding.weight.size(1)
      self.requires_grad = requires_grad
      self.kwargs = kwargs
  
imports: import os
  from collections import defaultdict
  from copy import deepcopy
  import json
  from typing import Callable, Union
  import numpy
  from fastNLP.core.log import logger
  from .embedding import TokenEmbedding
  from ...core import logger
  from ...core.vocabulary import Vocabulary
  from ...io.file_utils import PRETRAIN_STATIC_FILES, _get_embedding_url, cached_path
  from ...io.file_utils import _get_file_name_base_on_postfix
  from ...envs.imports import _NEED_IMPORT_TORCH
label_desc: Use image node_id 1 to create a new StaticEmbedding object from inherited base classes: TokenEmbedding with example: obj = StaticEmbedding(vocab, model_dir_or_name, embedding_dim, requires_grad, init_method, lower, dropout, word_dropout, normalize, min_freq)