def copy_checkpoint(checkpoint_path,
                    to_dir,
                    to_checkpoint_name = BEST_CHECKPOINT_FILENAME):
  """Copies a checkpoint to a new directory.

  Args:
    checkpoint_path: Specific checkpoint path to copy.
    to_dir: The target directory to copy to.
    to_checkpoint_name: The target checkpoint name to copy to.

  Raises:
    NotFoundError: When the given checkpoint is not found.
  """
  if not checkpoint_path:
    raise tf.errors.NotFoundError(None, None,
                                  "Checkpoint path must be non-empty")
  old_filenames = tf.io.gfile.glob(checkpoint_path + "*")
  if not old_filenames:
    raise tf.errors.NotFoundError(
        None, None, "Unable to find checkpoint: %s" % checkpoint_path)

  if not tf.io.gfile.exists(to_dir):
    tf.io.gfile.makedirs(to_dir)

  # Threaded copying helps to mitigate issues where large checkpoints do not
  # finish copying before being deleted.
  threads = []
  executor = concurrent.futures.ThreadPoolExecutor(max_workers=20)
  for old_filename in old_filenames:
    _, suffix = os.path.splitext(old_filename)
    new_filename = os.path.join(to_dir, to_checkpoint_name + suffix)
    threads.append(
        executor.submit(
            tf.io.gfile.copy, old_filename, new_filename, overwrite=True))
  concurrent.futures.wait(threads)
  tf.logging.info("Copied checkpoint %s to dir %s", checkpoint_path, to_dir)

  # Recreates a checkpoint file.
  new_checkpoint = os.path.join(to_dir, to_checkpoint_name)
  tf.train.update_checkpoint_state(to_dir, new_checkpoint)
  tf.logging.info("Writing new checkpoint file for %s", to_dir)
Copies a checkpoint to a new directory.

  Args:
    checkpoint_path: Specific checkpoint path to copy.
    to_dir: The target directory to copy to.
    to_checkpoint_name: The target checkpoint name to copy to.

  Raises:
    NotFoundError: When the given checkpoint is not found.
  
language/multivec/models/checkpoint_utils.py