code: def evaluate_env(
      env_name, seed, policy_hidden_size, stochastic, reuse, prefix
  ):
      def get_checkpoint_dir(checkpoint_list, limit, prefix):
          for checkpoint in checkpoint_list:
              if ("limitation_" + str(limit) in checkpoint) and (
                  prefix in checkpoint
              ):
                  return checkpoint
          return None
  
      def policy_fn(name, ob_space, ac_space, reuse=False):
          return mlp_policy.MlpPolicy(
              name=name,
              ob_space=ob_space,
              ac_space=ac_space,
              reuse=reuse,
              hid_size=policy_hidden_size,
              num_hid_layers=2,
          )
  
      data_path = os.path.join(
          "data", "deterministic.trpo." + env_name + ".0.00.npz"
      )
      dataset = load_dataset(data_path)
      checkpoint_list = glob.glob(
          os.path.join("checkpoint", "*" + env_name + ".*")
      )
      log = {
          "traj_limitation": [],
          "upper_bound": [],
          "avg_ret": [],
          "avg_len": [],
          "normalized_ret": [],
      }
      for i, limit in enumerate(CONFIG["traj_limitation"]):
          # Do one evaluation
          upper_bound = sum(dataset.rets[:limit]) / limit
          checkpoint_dir = get_checkpoint_dir(
              checkpoint_list, limit, prefix=prefix
          )
          checkpoint_path = tf.train.latest_checkpoint(checkpoint_dir)
          env = gym.make(env_name + "-v1")
          env.seed(seed)
          print(
              "Trajectory limitation: {}, Load checkpoint: {}, ".format(
                  limit, checkpoint_path
              )
          )
          avg_len, avg_ret = run_mujoco.runner(
              env,
              policy_fn,
              checkpoint_path,
              timesteps_per_batch=1024,
              number_trajs=10,
              stochastic_policy=stochastic,
              reuse=((i != 0) or reuse),
          )
          normalized_ret = avg_ret / upper_bound
          print(
              "Upper bound: {}, evaluation returns: {}, normalized scores: {}".format(
                  upper_bound, avg_ret, normalized_ret
              )
          )
          log["traj_limitation"].append(limit)
          log["upper_bound"].append(upper_bound)
          log["avg_ret"].append(avg_ret)
          log["avg_len"].append(avg_len)
          log["normalized_ret"].append(normalized_ret)
          env.close()
      return log
  
file_path: baselines/baselines/gail/gail-eval.py
imports: import argparse
  import os
  import glob
  import gym
  import matplotlib.pyplot
  import numpy
  import tensorflow
  from baselines.gail import run_mujoco
  from baselines.gail import mlp_policy
  from baselines.common import set_global_seeds, tf_util
  from baselines.common.misc_util import boolean_flag
  from baselines.gail.dataset.mujoco_dset import Mujoco_Dset
label_desc: Use image node_id 3 for calling a global function with example usage: evaluate_env(env_name, seed, policy_hidden_size, stochastic, reuse, prefix) and returns: log, None, mlp_policy, checkpoint