code: def wait_for_policy(
      policy_dir: Text,
      sleep_time_secs: int = _WAIT_DEFAULT_SLEEP_TIME_SECS,
      num_retries: int = _WAIT_DEFAULT_NUM_RETRIES,
      **saved_model_policy_args,
  ) -> py_tf_eager_policy.PyTFEagerPolicyBase:
      """Blocks until the policy in `policy_dir` becomes available.
  
      The default setting allows a fairly loose, but not infinite wait time of one
      days for this function to block checking the `policy_dir` in every seconds.
  
      Args:
        policy_dir: The directory containing the policy files.
        sleep_time_secs: Number of time in seconds slept between retries.
        num_retries: Number of times the existence of the file is checked.
        **saved_model_policy_args: Additional keyword arguments passed directly to
          the `SavedModelPyTFEagerPolicy` policy constructor which loads the policy
          from `policy_dir` once the policy becomes available.
  
      Returns:
        The policy loaded from the `policy_dir`.
  
      Raises:
        TimeoutError: If the policy does not become available during the number of
          retries.
      """
      # TODO(b/173815037): Write and wait for a DONE file instead.
      last_written_policy_file = os.path.join(
          policy_dir, "policy_specs.pbtxt"
      )
      wait_for_file(
          last_written_policy_file,
          sleep_time_secs=sleep_time_secs,
          num_retries=num_retries,
      )
      return py_tf_eager_policy.SavedModelPyTFEagerPolicy(
          policy_dir, **saved_model_policy_args
      )
  
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 3 for calling a global function with example usage: wait_for_policy(policy_dir, sleep_time_secs, num_retries) and returns: py_tf_eager_policy