class_docstr: Unit tests for policy gradient.
class_docstr_tok: ["Unit","tests","for","policy","gradient","."]
code: def test_rollout(self):
      action_space = spaces.Discrete(2)
      observation_space = spaces.Box(0, 1, (1,))
      sut = ActorCritic("", observation_space, action_space)
  
      sut._choose_action = Mock(side_effect=[(0, ""), (1, ""), (1, "")])
  
      sut.start(np.array([0.1], np.float32))
      sut.step(0.1, np.array([0.2], np.float32))
      sut.step(0.2, np.array([0.3], np.float32))
  
      self.assertEqual(sut._trajectory_rewards, [0.1, 0.2])
      self.assertEqual(sut._trajectory_actions, [0, 1, 1])
      self.assertEqual(sut._trajectory_states, [0.1, 0.2, 0.3])
  
      sut.end(0.3, np.array([0.4], np.float32))
  
      self.assertEqual(sut._trajectory_rewards, [0.1, 0.2, 0.3])
      self.assertEqual(sut._trajectory_actions, [0, 1, 1])
      self.assertEqual(sut._trajectory_states, [0.1, 0.2, 0.3])
  
imports: import unittest
  import cntk.contrib.deeprl.tests.spaces
  import numpy
  from cntk.contrib.deeprl.agent.policy_gradient import ActorCritic
  from cntk.layers import Dense
  from cntk.losses import cross_entropy_with_softmax
  from cntk.ops import input_variable, placeholder
label_desc: Use image node_id 7 for calling the PolicyGradientTest obj's underlying member method code with example usage: obj.test_rollout() without return types