code: def next_undecoded_checkpoint(model_dir, timeout_mins=240):
      """Yields successive checkpoints from model_dir."""
      last_ckpt = None
      last_step = 0
      while True:
          # Get the latest checkpoint.
          last_ckpt = contrib.training().wait_for_new_checkpoint(
              model_dir,
              last_ckpt,
              seconds_to_sleep=60,
              timeout=60 * timeout_mins,
          )
          # Get all the checkpoint from the model dir.
          ckpt_path = tf.train.get_checkpoint_state(model_dir)
          all_model_checkpoint_paths = (
              ckpt_path.all_model_checkpoint_paths
          )
          ckpt_step = np.inf
          next_ckpt = None
          # Find the next checkpoint to eval based on last_step.
          for ckpt in all_model_checkpoint_paths:
              step = int(os.path.basename(ckpt).split("-")[1])
              if step > last_step and step < ckpt_step:
                  ckpt_step = step
                  next_ckpt = ckpt
  
          # If all the checkpoints have been evaluated.
          if last_ckpt is None and next_ckpt is None:
              tf.logging.info(
                  "Eval timeout: no new checkpoints within %dm"
                  % timeout_mins
              )
              break
  
          if next_ckpt is not None:
              last_step = ckpt_step
              last_ckpt = next_ckpt
  
          yield last_ckpt
  
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 2 for calling a global function with example usage: next_undecoded_checkpoint(model_dir, timeout_mins) without return types