code: def next_checkpoint(model_dir, timeout_mins=240):
      """Yields successive checkpoints from model_dir.
  
      Args:
        model_dir: The directory in which checkpoints are saved.
        timeout_mins: The maximum amount of time in minutes to wait
                      between checkpoints. Set this to -1 to wait indefinitely.
      Yields:
        last_ckpt: a new checkpoint path, or None if the timeout was reached.
      """
      last_ckpt = None
      timeout_secs = None
      if timeout_mins != -1:
          timeout_secs = timeout_mins * 60
      while True:
          last_ckpt = contrib.training().wait_for_new_checkpoint(
              model_dir,
              last_ckpt,
              seconds_to_sleep=60,
              timeout=timeout_secs,
          )
  
          if last_ckpt is None:
              tf.logging.info(
                  "Eval timeout: no new checkpoints within %dm"
                  % timeout_mins
              )
              break
  
          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 1 for calling a global function with example usage: next_checkpoint(model_dir, timeout_mins) without return types