class_docstr: Callback for evaluating an agent.
  
  :param eval_env: (Union[gym.Env, VecEnv]) The environment used for initialization
  :param callback_on_new_best: (Optional[BaseCallback]) Callback to trigger
      when there is a new best model according to the `mean_reward`
  :param n_eval_episodes: (int) The number of episodes to test the agent
  :param eval_freq: (int) Evaluate the agent every eval_freq call of the callback.
  :param log_path: (str) Path to a folder where the evaluations (`evaluations.npz`)
      will be saved. It will be updated at each evaluation.
  :param best_model_save_path: (str) Path to a folder where the best model
      according to performance on the eval env will be saved.
  :param deterministic: (bool) Whether the evaluation should
      use a stochastic or deterministic actions.
  :param render: (bool) Whether to render or not the environment during evaluation
  :param verbose: (int)
class_docstr_tok: ["Callback","for","evaluating","an","agent",".",":","param","eval_env",":","(","Union","[","gym.Env",",","VecEnv","]",")","The","environment","used","for","initialization",":","param","callback_on_new_best",":","(","Optional","[","BaseCallback","]",")","Callback","to","trigger","when","there","is","a","new","best","model","according","to","the","`","mean_reward","`",":","param","n_eval_episodes",":","(","int",")","The","number","of","episodes","to","test","the","agent",":","param","eval_freq",":","(","int",")","Evaluate","the","agent","every","eval_freq","call","of","the","callback",".",":","param","log_path",":","(","str",")","Path","to","a","folder","where","the","evaluations","(","`","evaluations.npz","`",")","will","be","saved",".","It","will","be","updated","at","each","evaluation",".",":","param","best_model_save_path",":","(","str",")","Path","to","a","folder","where","the","best","model","according","to","performance","on","the","eval","env","will","be","saved",".",":","param","deterministic",":","(","bool",")","Whether","the","evaluation","should","use","a","stochastic","or","deterministic","actions",".",":","param","render",":","(","bool",")","Whether","to","render","or","not","the","environment","during","evaluation",":","param","verbose",":","(","int",")"]
code: def __init__(
      self,
      eval_env: Union[gym.Env, VecEnv],
      callback_on_new_best: Optional[BaseCallback] = None,
      n_eval_episodes: int = 5,
      eval_freq: int = 10000,
      log_path: Optional[str] = None,
      best_model_save_path: Optional[str] = None,
      deterministic: bool = True,
      render: bool = False,
      verbose: int = 1,
  ):
      super(EvalCallback, self).__init__(
          callback_on_new_best, verbose=verbose
      )
      self.n_eval_episodes = n_eval_episodes
      self.eval_freq = eval_freq
      self.best_mean_reward = -np.inf
      self.last_mean_reward = -np.inf
      self.deterministic = deterministic
      self.render = render
  
      # Convert to VecEnv for consistency
      if not isinstance(eval_env, VecEnv):
          eval_env = DummyVecEnv([lambda: eval_env])
  
      assert (
          eval_env.num_envs == 1
      ), "You must pass only one environment for evaluation"
  
      self.eval_env = eval_env
      self.best_model_save_path = best_model_save_path
      # Logs will be written in `evaluations.npz`
      if log_path is not None:
          log_path = os.path.join(log_path, "evaluations")
      self.log_path = log_path
      self.evaluations_results = []
      self.evaluations_timesteps = []
      self.evaluations_length = []
  
imports: import os
  from abc import ABC
  import warnings
  import typing
  from typing import Union, List, Dict, Any, Optional
  import gym
  import numpy
  from stable_baselines.common.vec_env import VecEnv, sync_envs_normalization, DummyVecEnv
  from stable_baselines.common.evaluation import evaluate_policy
  from stable_baselines import logger
label_desc: Use image node_id 1 to create a new EvalCallback object from inherited base classes: EventCallback with example: obj = EvalCallback(eval_env, callback_on_new_best, n_eval_episodes, eval_freq, log_path, best_model_save_path, deterministic, render, verbose)