code: def eval_episodes(
      target_rew,
      env,
      state_dim,
      act_dim,
      agent,
      max_ep_len,
      scale,
      state_mean,
      state_std,
      device,
  ):
      returns, lengths = [], []
      num_eval_episodes = 100
      for _ in tqdm(range(num_eval_episodes), desc="eval"):
          with torch.no_grad():
              ret, length = evaluate_episode_rtg(
                  env,
                  state_dim,
                  act_dim,
                  agent,
                  max_ep_len=max_ep_len,
                  scale=scale,
                  target_return=target_rew / scale,
                  state_mean=state_mean,
                  state_std=state_std,
                  device=device,
              )
          returns.append(ret)
          lengths.append(length)
      return {
          f"target_{target_rew}_return_mean": np.mean(returns),
          f"target_{target_rew}_return_std": np.std(returns),
          f"target_{target_rew}_length_mean": np.mean(lengths),
          f"target_{target_rew}_length_std": np.std(lengths),
      }
  
imports: import numpy
  import torch
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling a global function with example usage: eval_episodes(target_rew, env, state_dim, act_dim, agent, max_ep_len, scale, state_mean, state_std, device) and returns: dict