class_docstr: Restore variables from a checkpoint path.
docstr: Load variables from checkpoint.
  
  New model variables have the following name foramt:
  new_model_scope/old_model_scope/xxx/xxx:0 To find the map of
  name to variable, need to strip the new_model_scope and then
  match the old_model_scope and remove the suffix :0.
code: def begin(self):
      """Load variables from checkpoint.
  
      New model variables have the following name foramt:
      new_model_scope/old_model_scope/xxx/xxx:0 To find the map of
      name to variable, need to strip the new_model_scope and then
      match the old_model_scope and remove the suffix :0.
  
      """
      variables_to_restore = (
          contrib.framework().get_variables_to_restore(
              include=self._include, exclude=self._exclude
          )
      )
      # remove new_model_scope from variable name prefix
      assignment_map = {
          variable.name[len(self._new_model_scope) :]: variable
          for variable in variables_to_restore
          if variable.name.startswith(self._new_model_scope)
      }
      # remove :0 from variable name suffix
      assignment_map = {
          name.split(":")[0]: variable
          for name, variable in six.iteritems(assignment_map)
          if name.startswith(self._old_model_scope)
      }
      self._assignment_map = assignment_map
  
      tf.logging.info(
          "restoring %d variables from checkpoint %s"
          % (len(assignment_map), self._checkpoint_path)
      )
      tf.train.init_from_checkpoint(
          self._checkpoint_path, self._assignment_map
      )
  
file_path: tensor2tensor/tensor2tensor/utils/restore_hook.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import six
  from tensor2tensor.utils import contrib
  import tensorflow.compat.v1
label_desc: Use image node_id 2 for calling the RestoreHook obj's underlying member method code with example usage: obj.begin() without return types