code: def test_cache_embeds(self):
      embeddings_ref = PretrainedEmbedding()
      embeddings_ref.load_pretrained_embeddings(EMBED_RAW_PATH)
      with tempfile.NamedTemporaryFile(
          delete=False, suffix=".{}".format("cached")
      ) as cached_path:
          embeddings_ref.cache_pretrained_embeddings(cached_path.name)
          embeddings_cached = PretrainedEmbedding()
          embeddings_cached.load_cached_embeddings(cached_path.name)
  
      np.testing.assert_array_equal(
          sorted(embeddings_cached.stoi.keys()),
          sorted(embeddings_ref.stoi.keys()),
      )
      np.testing.assert_array_equal(
          embeddings_cached.embed_vocab, embeddings_ref.embed_vocab
      )
      np.testing.assert_array_equal(
          sorted(embeddings_cached.stoi.values()),
          sorted(embeddings_ref.stoi.values()),
      )
      for word_idx in embeddings_ref.stoi.values():
          np.testing.assert_array_almost_equal(
              embeddings_cached.embedding_vectors[word_idx],
              embeddings_ref.embedding_vectors[word_idx],
          )
  
file_path: pytext/pytext/utils/tests/embeddings_utils_test.py
imports: import tempfile
  import unittest
  import numpy
  from pytext.common.constants import DatasetFieldName
  from pytext.config.field_config import DocLabelConfig, EmbedInitStrategy, FeatureConfig, WordFeatConfig, WordLabelConfig
  from pytext.data.featurizer import SimpleFeaturizer
  from pytext.utils.test import import_tests_module
  from pytorch.text.fb.utils.embeddings import PretrainedEmbedding
label_desc: Use image node_id 2 for calling the PretrainedEmbedsTest obj's underlying member method code with example usage: obj.test_cache_embeds() without return types