code: def test_get_action():
      # discrete control
      action_space = DiscreteActionSpace(3)
      epsilon_schedule = LinearSchedule(1.0, 1.0, 1000)
      policy = EGreedy(
          action_space, epsilon_schedule, evaluation_epsilon=0
      )
  
      # verify that test phase gives greedy actions (evaluation_epsilon = 0)
      policy.change_phase(RunPhase.TEST)
      for i in range(100):
          best_action, _ = policy.get_action(np.array([10, 20, 30]))
          assert best_action == 2
  
      # verify that train phase gives uniform actions (exploration = 1)
      policy.change_phase(RunPhase.TRAIN)
      counters = np.array([0, 0, 0])
      for i in range(30000):
          best_action, _ = policy.get_action(np.array([10, 20, 30]))
          counters[best_action] += 1
      assert np.all(counters > 9500)
  
file_path: coach/rl_coach/tests/exploration_policies/test_e_greedy.py
imports: import os
  import sys
  import pytest
  from rl_coach.spaces import DiscreteActionSpace
  from rl_coach.exploration_policies.e_greedy import EGreedy
  from rl_coach.schedules import LinearSchedule
  import numpy
  from rl_coach.core_types import RunPhase
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_action() without return types