code: def _parse_memory(self, actor_state):
      mem = actor_state.memory
      n = len(mem)
      episode_shaping_reward = np.sum(
          [exp.info["shaping_reward"] for exp in mem]
      )
      episode_env_reward = np.sum(
          [exp.info["env_reward"] for exp in mem]
      )
  
      with self.lock:
          if actor_state.model_name == self.cur_model:
              self.evaluate_result.append(
                  {
                      "shaping_reward": episode_shaping_reward,
                      "env_reward": episode_env_reward,
                      "episode_length": mem[-1].info["frame_count"],
                      "falldown": not mem[-1].info["timeout"],
                  }
              )
              logger.info(
                  "{}, finish_cnt: {}".format(
                      self.cur_model, len(self.evaluate_result)
                  )
              )
              logger.info("{}".format(self.evaluate_result[-1]))
              if len(self.evaluate_result) >= args.evaluate_times:
                  mean_value = {}
                  for key in self.evaluate_result[0].keys():
                      mean_value[key] = np.mean(
                          [x[key] for x in self.evaluate_result]
                      )
                  logger.info(
                      "Model: {}, mean_value: {}".format(
                          self.cur_model, mean_value
                      )
                  )
  
                  eval_num = len(self.evaluate_result)
                  falldown_num = len(
                      [x for x in self.evaluate_result if x["falldown"]]
                  )
                  falldown_rate = falldown_num / eval_num
                  logger.info("Falldown rate: {}".format(falldown_rate))
                  for key in self.evaluate_result[0].keys():
                      mean_value[key] = np.mean(
                          [
                              x[key]
                              for x in self.evaluate_result
                              if not x["falldown"]
                          ]
                      )
                  logger.info(
                      "Model: {}, Exclude falldown, mean_value: {}".format(
                          self.cur_model, mean_value
                      )
                  )
                  if (
                      mean_value["shaping_reward"]
                      > self.best_shaping_reward
                  ):
                      self.best_shaping_reward = mean_value[
                          "shaping_reward"
                      ]
                      copy2(self.cur_model, "./model_zoo")
                      logger.info(
                          "[best shaping reward updated:{}] path:{}".format(
                              self.best_shaping_reward, self.cur_model
                          )
                      )
                  if (
                      mean_value["env_reward"] > self.best_env_reward
                      and falldown_rate < 0.3
                  ):
                      self.best_env_reward = mean_value["env_reward"]
                      copy2(self.cur_model, "./model_zoo")
                      logger.info(
                          "[best env reward updated:{}] path:{}, falldown rate: {}".format(
                              self.best_env_reward,
                              self.cur_model,
                              falldown_num / eval_num,
                          )
                      )
  
                  self.evaluate_result = []
                  while True:
                      model_path = self.model_queue.get()
                      if not args.offline_evaluate:
                          # online evaluate
                          while not self.model_queue.empty():
                              model_path = self.model_queue.get()
                      try:
                          self.agent.restore(model_path)
                          break
                      except Exception as e:
                          logger.warn(
                              "Agent restore Exception: {} ".format(e)
                          )
                  self.cur_model = model_path
          else:
              actor_state.model_name = self.cur_model
      actor_state.reset()
  
imports: import os
  import parl
  import queue
  import six
  import threading
  import time
  import numpy
  from actor import Actor
  from opensim_model import OpenSimModel
  from opensim_agent import OpenSimAgent
  from parl.utils import logger, summary, get_gpu_count
  from parl.utils.window_stat import WindowStat
  from parl.remote.client import get_global_client
  from parl.utils import machine_info
  from shutil import copy2
label_desc: Use image node_id 6 for calling the Evaluator obj's underlying member method code with example usage: obj._parse_memory(actor_state) without return types