code: def run_policy(
      env, get_action, max_ep_len=None, num_episodes=100, render=True
  ):
      assert env is not None, (
          "Environment not found!\n\n It looks like the environment wasn't saved, "
          + "and we can't run the agent in it. :( \n\n Check out the readthedocs "
          + "page on Experiment Outputs for how to handle this situation."
      )
  
      logger = EpochLogger()
      o, r, d, ep_ret, ep_len, n = env.reset(), 0, False, 0, 0, 0
      while n < num_episodes:
          if render:
              env.render()
              time.sleep(1e-3)
  
          a = get_action(o)
          o, r, d, _ = env.step(a)
          ep_ret += r
          ep_len += 1
  
          if d or (ep_len == max_ep_len):
              logger.store(EpRet=ep_ret, EpLen=ep_len)
              print(
                  "Episode %d \t EpRet %.3f \t EpLen %d"
                  % (n, ep_ret, ep_len)
              )
              o, r, d, ep_ret, ep_len = env.reset(), 0, False, 0, 0
              n += 1
  
      logger.log_tabular("EpRet", with_min_and_max=True)
      logger.log_tabular("EpLen", average_only=True)
      logger.dump_tabular()
  
file_path: spinningup/spinup/utils/test_policy.py
imports: import time
  import joblib
  import os
  import os.path
  import tensorflow
  import torch
  from spinup import EpochLogger
  from spinup.utils.logx import restore_tf_graph
label_desc: Use image node_id 4 for calling a global function with example usage: run_policy(env, get_action, max_ep_len, num_episodes, render) without return types