code: def test_file_archiving(self):
      # This happens to be a good place to test auxiliary file archiving.
      # Train the model
      params = Params.from_file(
          self.FIXTURES_ROOT
          / "elmo"
          / "config"
          / "characters_token_embedder.json"
      )
      serialization_dir = os.path.join(self.TEST_DIR, "serialization")
      train_model(params, serialization_dir)
  
      # Inspect the archive
      archive_file = os.path.join(serialization_dir, "model.tar.gz")
      unarchive_dir = os.path.join(self.TEST_DIR, "unarchive")
      with tarfile.open(archive_file, "r:gz") as archive:
          archive.extractall(unarchive_dir)
  
      # It should contain `files_to_archive.json`
      fta_file = os.path.join(unarchive_dir, "files_to_archive.json")
      assert os.path.exists(fta_file)
  
      # Which should properly contain { flattened_key -> original_filename }
      with open(fta_file) as fta:
          files_to_archive = json.loads(fta.read())
  
      assert files_to_archive == {
          "model.text_field_embedder.token_embedders.elmo.options_file": unicode(
              pathlib.Path("allennlp")
              / "tests"
              / "fixtures"
              / "elmo"
              / "options.json"
          ),
          "model.text_field_embedder.token_embedders.elmo.weight_file": unicode(
              pathlib.Path("allennlp")
              / "tests"
              / "fixtures"
              / "elmo"
              / "lm_weights.hdf5"
          ),
      }
  
      # Check that the unarchived contents of those files match the original contents.
      for key, original_filename in list(files_to_archive.items()):
          new_filename = os.path.join(unarchive_dir, "fta", key)
          assert filecmp.cmp(original_filename, new_filename)
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import filecmp
  import json
  import os
  import pathlib
  import tarfile
  import torch
  from allennlp.commands.train import train_model
  from allennlp.common import Params
  from allennlp.common.testing import ModelTestCase
  from allennlp.data.dataset import Batch
  from allennlp.modules.token_embedders import ElmoTokenEmbedder
  from io import open
label_desc: Use image node_id 4 for calling the TestElmoTokenEmbedder obj's underlying member method code with example usage: obj.test_file_archiving() without return types