code: def archive_model(
      serialization_dir: Union[str, PathLike],
      weights: str = _DEFAULT_WEIGHTS,
      archive_path: Union[str, PathLike] = None,
      include_in_archive: Optional[List[str]] = None,
  ) -> str:
      """
      Archive the model weights, its training configuration, and its vocabulary to `model.tar.gz`.
  
      # Parameters
  
      serialization_dir : `str`
          The directory where the weights and vocabulary are written out.
      weights : `str`, optional (default=`_DEFAULT_WEIGHTS`)
          Which weights file to include in the archive. The default is `best.th`.
      archive_path : `str`, optional, (default = `None`)
          A full path to serialize the model to. The default is "model.tar.gz" inside the
          serialization_dir. If you pass a directory here, we'll serialize the model
          to "model.tar.gz" inside the directory.
      include_in_archive : `List[str]`, optional, (default = `None`)
          Paths relative to `serialization_dir` that should be archived in addition to the default ones.
  
      # Returns
  
      The final archive path.
      """
      extra_copy_of_weights_just_for_mypy = Path(weights)
      if extra_copy_of_weights_just_for_mypy.is_absolute():
          weights_file = extra_copy_of_weights_just_for_mypy
      else:
          weights_file = (
              Path(serialization_dir)
              / extra_copy_of_weights_just_for_mypy
          )
      if not os.path.exists(weights_file):
          err_msg = f"weights file '{weights_file}' does not exist, unable to archive model"
          logger.error(err_msg)
          raise RuntimeError(err_msg)
  
      config_file = os.path.join(serialization_dir, CONFIG_NAME)
      if not os.path.exists(config_file):
          err_msg = f"config file '{config_file}' does not exist, unable to archive model"
          logger.error(err_msg)
          raise RuntimeError(err_msg)
  
      meta_file = os.path.join(serialization_dir, META_NAME)
  
      if archive_path is not None:
          archive_file = archive_path
          if os.path.isdir(archive_file):
              archive_file = os.path.join(archive_file, "model.tar.gz")
      else:
          archive_file = os.path.join(serialization_dir, "model.tar.gz")
  
      logger.info(
          "archiving weights and vocabulary to %s", archive_file
      )
      with tarfile.open(archive_file, "w:gz") as archive:
          archive.add(config_file, arcname=CONFIG_NAME)
          archive.add(weights_file, arcname=_WEIGHTS_NAME)
          archive.add(
              os.path.join(serialization_dir, "vocabulary"),
              arcname="vocabulary",
          )
          if os.path.exists(meta_file):
              archive.add(meta_file, arcname=META_NAME)
          else:
              logger.warning("meta file %s does not exist", meta_file)
  
          if include_in_archive is not None:
              for archival_target in include_in_archive:
                  archival_target_path = os.path.join(
                      serialization_dir, archival_target
                  )
                  for path in glob.glob(archival_target_path):
                      if os.path.exists(path):
                          arcname = path[
                              len(os.path.join(serialization_dir, "")) :
                          ]
                          archive.add(path, arcname=arcname)
  
      return str(archive_file)
  
imports: from os import PathLike
  from pathlib import Path
  from typing import Tuple, NamedTuple, Union, Dict, Any, List, Optional
  import logging
  import os
  import tempfile
  import tarfile
  import shutil
  from contextlib import contextmanager
  import glob
  import warnings
  from torch.nn import Module
  from allennlp.version import VERSION, _MAJOR, _MINOR, _PATCH
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.file_utils import cached_path
  from allennlp.common.meta import Meta, META_NAME
  from allennlp.common.params import Params
  from allennlp.data.dataset_readers import DatasetReader
  from allennlp.models.model import Model, _DEFAULT_WEIGHTS
label_desc: Use image node_id 2 for calling a global function with example usage: archive_model(serialization_dir, weights, archive_path, include_in_archive) and returns: str