code: def eval_policy(
      env: EnvWrapper,
      serving_policy: Policy,
      num_eval_episodes: int,
      serving: bool = True,
  ) -> np.ndarray:
      agent = (
          Agent.create_for_env_with_serving_policy(env, serving_policy)
          if serving
          else Agent.create_for_env(env, serving_policy)
      )
  
      eval_rewards = evaluate_for_n_episodes(
          n=num_eval_episodes,
          env=env,
          agent=agent,
          max_steps=env.max_steps,
          num_processes=1,
      ).squeeze(1)
  
      logger.info("============Eval rewards==============")
      logger.info(eval_rewards)
      mean_eval = np.mean(eval_rewards)
      logger.info(f"average: {mean_eval};\tmax: {np.max(eval_rewards)}")
      return np.array(eval_rewards)
  
imports: import logging
  import os
  import pprint
  import unittest
  import uuid
  from typing import Optional
  import numpy
  import pytest
  import pytorch_lightning
  import torch
  from parameterized import parameterized
  from reagent.gym.agents.agent import Agent
  from reagent.gym.datasets.episodic_dataset import EpisodicDataset
  from reagent.gym.datasets.replay_buffer_dataset import ReplayBufferDataset
  from reagent.gym.envs import Env__Union
  from reagent.gym.envs.env_wrapper import EnvWrapper
  from reagent.gym.policies.policy import Policy
  from reagent.gym.policies.random_policies import make_random_policy_for_env
  from reagent.gym.runners.gymrunner import evaluate_for_n_episodes
  from reagent.gym.utils import build_normalizer, fill_replay_buffer
  from reagent.model_managers.union import ModelManager__Union
  from reagent.replay_memory.circular_replay_buffer import ReplayBuffer
  from reagent.test.base.horizon_test_base import HorizonTestBase
label_desc: Use image node_id 1 for calling a global function with example usage: eval_policy(env, serving_policy, num_eval_episodes, serving) and returns: np