code: def test_save_load_static_embed(self):
      static_test_folder = "static_save_test"
      try:
          # 测试包含no_create_entry
          os.makedirs(static_test_folder, exist_ok=True)
  
          vocab = Vocabulary().add_word_lst(
              ["The", "a", "notinfile1", "A"]
          )
          vocab.add_word_lst(
              ["notinfile2", "notinfile2"], no_create_entry=True
          )
          embed = StaticEmbedding(
              vocab,
              model_dir_or_name=tests_folder
              + "/helpers/data/embedding/small_static_embedding/"
              "glove.6B.50d_test.txt",
          )
          embed.save(static_test_folder)
          load_embed = StaticEmbedding.load(static_test_folder)
          words = torch.randint(len(vocab), size=(2, 20))
          assert (embed(words) - load_embed(words)).sum() == 0
  
          # 测试不包含no_create_entry
          vocab = Vocabulary().add_word_lst(
              ["The", "a", "notinfile1", "A"]
          )
          embed = StaticEmbedding(
              vocab,
              model_dir_or_name=tests_folder
              + "/helpers/data/embedding/small_static_embedding/"
              "glove.6B.50d_test.txt",
          )
          embed.save(static_test_folder)
          load_embed = StaticEmbedding.load(static_test_folder)
          words = torch.randint(len(vocab), size=(2, 20))
          assert (embed(words) - load_embed(words)).sum() == 0
  
          # 测试lower, min_freq
          vocab = Vocabulary().add_word_lst(
              ["The", "the", "the", "A", "a", "B"]
          )
          embed = StaticEmbedding(
              vocab,
              model_dir_or_name=tests_folder
              + "/helpers/data/embedding/small_static_embedding/"
              "glove.6B.50d_test.txt",
              min_freq=2,
              lower=True,
          )
          embed.save(static_test_folder)
          load_embed = StaticEmbedding.load(static_test_folder)
          words = torch.randint(len(vocab), size=(2, 20))
          assert (embed(words) - load_embed(words)).sum() == 0
  
          # 测试random的embedding
          vocab = Vocabulary().add_word_lst(
              ["The", "the", "the", "A", "a", "B"]
          )
          vocab = vocab.add_word_lst(["b"], no_create_entry=True)
          embed = StaticEmbedding(
              vocab,
              model_dir_or_name=None,
              embedding_dim=4,
              min_freq=2,
              lower=True,
              normalize=True,
          )
          embed.weight.data += 0.2  # 使得它不是normalize
          embed.save(static_test_folder)
          load_embed = StaticEmbedding.load(static_test_folder)
          words = torch.randint(len(vocab), size=(2, 20))
          assert (embed(words) - load_embed(words)).sum() == 0
  
      finally:
          if os.path.isdir(static_test_folder):
              import shutil
  
              shutil.rmtree(static_test_folder)
  
file_path: fastNLP/tests/embeddings/torch/test_static_embedding.py
imports: import pytest
  import os
  from fastNLP.embeddings.torch import StaticEmbedding
  from fastNLP import Vocabulary
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  import numpy
label_desc: Use image node_id 6 for calling the TestLoad obj's underlying member method code with example usage: obj.test_save_load_static_embed() without return types