code: def test_save_knowledge_bank(self):
      # Adds an embedding with values [4, 5].
      pattern1 = (
          FLAGS.test_tmpdir
          + "/knowledge_bank_data_[0-9]+_[0-9]+_[0-9]+"
          + "/emb1/embedding_store_meta_data.pbtxt"
      )
      de_ops.dynamic_embedding_update(
          ["first"],
          tf.constant([4.0, 5.0]),
          self._config,
          "emb1",
          service_address=self._kbs_address,
      )
      saved_paths = io_ops.save_knowledge_bank(
          FLAGS.test_tmpdir, self._kbs_address
      )
      self.assertLen(saved_paths, 1)
      self.assertRegex(saved_paths[0].numpy()[0].decode(), pattern1)
  
      # Add another embedding data.
      pattern2 = (
          FLAGS.test_tmpdir
          + "/knowledge_bank_data_[0-9]+_[0-9]+_[0-9]+"
          + "/emb2/embedding_store_meta_data.pbtxt"
      )
      de_ops.dynamic_embedding_update(
          ["first"],
          tf.constant([5.0, 6.0]),
          self._config,
          "emb2",
          service_address=self._kbs_address,
      )
      saved_paths = io_ops.save_knowledge_bank(
          FLAGS.test_tmpdir, self._kbs_address
      )
      self.assertLen(saved_paths, 2)
      self.assertRegex(saved_paths[0].numpy()[0].decode(), pattern1)
      self.assertRegex(saved_paths[1].numpy()[0].decode(), pattern2)
  
      # Only save selected embedding.
      new_saved_paths = io_ops.save_knowledge_bank(
          FLAGS.test_tmpdir, self._kbs_address, var_names=["emb2"]
      )
      self.assertLen(new_saved_paths, 1)
      self.assertRegex(new_saved_paths[0].numpy()[0].decode(), pattern2)
      self.assertNotEqual(
          new_saved_paths[0].numpy()[0], saved_paths[0].numpy()[0]
      )
  
file_path: neural-structured-learning/research/carls/io_ops_test.py
imports: from absl import flags
  from research.carls import context
  from research.carls import dynamic_embedding_ops
  from research.carls import io_ops
  from research.carls.testing import test_util
  import tensorflow
label_desc: Use image node_id 3 for calling the IoOpsTest obj's underlying member method code with example usage: obj.test_save_knowledge_bank() without return types