code: def wait_for_file(
      file_path: Text,
      sleep_time_secs: int = _WAIT_DEFAULT_SLEEP_TIME_SECS,
      num_retries: int = _WAIT_DEFAULT_NUM_RETRIES,
  ) -> Text:
      """Blocks until the file at `file_path` becomes available.
  
      The default setting allows a fairly loose, but not infinite wait time of one
      days for this function to block checking the `file_path` in every seconds.
  
      Args:
        file_path: The path to the file that we are waiting for.
        sleep_time_secs: Number of time in seconds slept between retries.
        num_retries: Number of times the existence of the file is checked.
  
      Returns:
        The original `file_path`.
  
      Raises:
        TimeoutError: If the file does not become available during the number of
          trials.
      """
  
      def _is_file_missing(file_path=file_path):
          """Checks if the file is (still) missing, i.e. more wait is necessary."""
          try:
              stat = tf.io.gfile.stat(file_path)
          except tf.errors.NotFoundError:
              return True
          found_file = stat.length <= 0
          logging.info(
              "Checking for file %s (%s)",
              file_path,
              "found" if found_file else "not found",
          )
          return found_file
  
      wait_for_predicate(
          wait_predicate_fn=_is_file_missing,
          sleep_time_secs=sleep_time_secs,
          num_retries=num_retries,
      )
  
      return file_path
  
file_path: agents/tf_agents/train/utils/train_utils.py
imports: import os
  import time
  from typing import Callable, Text, Tuple
  from absl import logging
  import tensorflow.compat.v2
  from tf_agents.agents import tf_agent
  from tf_agents.policies import py_tf_eager_policy
  from tf_agents.typing import types
  from tf_agents.utils import lazy_loader
label_desc: Use image node_id 4 for calling a global function with example usage: wait_for_file(file_path, sleep_time_secs, num_retries) and returns: file_path, found_file, True