code: def restore_checkpoint(ckpt_dir, saver, sess, must_restore=False):
      """Restore from a checkpoint."""
      ckpt = tf.train.get_checkpoint_state(ckpt_dir)
      if must_restore and not ckpt:
          raise ValueError("No checkpoint found in %s" % ckpt_dir)
      if not ckpt:
          return 0
  
      path = ckpt.model_checkpoint_path
      tf.logging.info("Restoring checkpoint %s", path)
      saver.restore(sess, path)
      step = int(path.split("-")[-1])
      return step
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import contextlib
  import json
  import os
  import random
  import numpy
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import decoding
  from tensor2tensor.utils import devices
  from tensor2tensor.utils import hparams_lib
  from tensor2tensor.utils import metrics_hook
  from tensor2tensor.utils import mlperf_log
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python import debug
label_desc: Use image node_id 11 for calling a global function with example usage: restore_checkpoint(ckpt_dir, saver, sess, must_restore) and returns: step, int