code: def prepare_pretrained_model_for_restoring(
      output_folder_name,
      epoch_number,
      model_name,
      delete_token_mappings=False,
  ):
      """
      Copy the dataset.pickle, parameters.ini, and model checkpoint files after
      removing the data used for training.
  
      The dataset and labels are deleted from dataset.pickle by default. The only
      information about the dataset that remain in the pretrained model
      is the list of tokens that appears in the dataset and the corresponding token
      embeddings learned from the dataset.
  
      If delete_token_mappings is set to True, index_to_token and token_to_index
      mappings are deleted from dataset.pickle additionally,
      and the corresponding token embeddings are deleted from the model checkpoint
      files. In this case, the pretrained model would not contain
      any information about the dataset used for training the model.
  
      If you wish to share a pretrained model with delete_token_mappings = True,
      it is highly recommended to use some external pre-trained token
      embeddings and freeze them while training the model to obtain high performance.
      This can be done by specifying the token_pretrained_embedding_filepath
      and setting freeze_token_embeddings = True in parameters.ini for training.
      """
      input_model_folder = os.path.join(
          ".", "output", output_folder_name, "model"
      )
      output_model_folder = os.path.join(
          ".", "trained_models", model_name
      )
      utils.create_folder_if_not_exists(output_model_folder)
  
      # trim and copy dataset.pickle
      input_dataset_filepath = os.path.join(
          input_model_folder, "dataset.pickle"
      )
      output_dataset_filepath = os.path.join(
          output_model_folder, "dataset.pickle"
      )
      trim_dataset_pickle(
          input_dataset_filepath,
          output_dataset_filepath,
          delete_token_mappings=delete_token_mappings,
      )
  
      # copy parameters.ini
      parameters_filepath = os.path.join(
          input_model_folder, "parameters.ini"
      )
      shutil.copy(parameters_filepath, output_model_folder)
  
      # (trim and) copy checkpoint files
      epoch_number_string = str(epoch_number).zfill(5)
      if delete_token_mappings:
          input_checkpoint_filepath = os.path.join(
              input_model_folder,
              "model_{0}.ckpt".format(epoch_number_string),
          )
          output_checkpoint_filepath = os.path.join(
              output_model_folder, "model.ckpt"
          )
          trim_model_checkpoint(
              parameters_filepath,
              output_dataset_filepath,
              input_checkpoint_filepath,
              output_checkpoint_filepath,
          )
      else:
          for filepath in glob.glob(
              os.path.join(
                  input_model_folder,
                  "model_{0}.ckpt*".format(epoch_number_string),
              )
          ):
              shutil.copyfile(
                  filepath,
                  os.path.join(
                      output_model_folder,
                      os.path.basename(filepath).replace(
                          "_" + epoch_number_string, ""
                      ),
                  ),
              )
  
file_path: NeuroNER/neuroner/prepare_pretrained_model.py
imports: import glob
  import os
  import pickle
  from pprint import pprint
  import shutil
  import utils
  from entity_lstm import EntityLSTM
  import tensorflow
  from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
  from neuroner import utils_tf
  from neuroner import neuromodel
label_desc: Use image node_id 3 for calling a global function with example usage: prepare_pretrained_model_for_restoring(output_folder_name, epoch_number, model_name, delete_token_mappings) without return types