class_docstr: Unit tests for QLearning.
class_docstr_tok: ["Unit","tests","for","QLearning","."]
code: def test_update_q_dqn_prioritized_replay(
      self, mock_parameters, mock_replay_memory
  ):
      self._setup_parameters(mock_parameters.return_value)
      mock_parameters.return_value.use_prioritized_replay = True
      self._setup_prioritized_replay_memory(
          mock_replay_memory.return_value
      )
  
      action_space = spaces.Discrete(2)
      observation_space = spaces.Box(0, 1, (1,))
      sut = QLearning("", observation_space, action_space)
  
      def new_q_value(self):
          return np.array([[[0.2, 0.1]]], np.float32)
  
      sut._q.eval = MagicMock(side_effect=new_q_value)
      sut._target_q.eval = MagicMock(
          return_value=np.array([[[0.3, 0.4]]], np.float32)
      )
      sut._trainer = MagicMock()
  
      sut._update_q_periodically()
  
      self.assertEqual(sut._trainer.train_minibatch.call_count, 1)
      np.testing.assert_array_equal(
          sut._trainer.train_minibatch.call_args[0][0][
              sut._input_variables
          ],
          [
              np.array([0.1], np.float32),
              np.array([0.3], np.float32),
              np.array([0.1], np.float32),
          ],
      )
      np.testing.assert_array_equal(
          sut._trainer.train_minibatch.call_args[0][0][
              sut._output_variables
          ],
          [
              # 10 (reward) + 0.9 (gamma) x 0.4 (max q_target)
              np.array([10.36, 0.1], np.float32),
              # 11 (reward) + 0.9 (gamma) x 0.4 (max q_target)
              np.array([0.2, 11.36], np.float32),
              np.array([10.36, 0.1], np.float32),
          ],
      )
      np.testing.assert_almost_equal(
          sut._trainer.train_minibatch.call_args[0][0][
              sut._weight_variables
          ],
          [[0.16666667], [0.66666667], [0.16666667]],
      )
      self.assertAlmostEqual(
          sut._replay_memory.update_priority.call_args[0][0][3],
          105.2676,
      )  # (10.16 + 0.1)^2
      self.assertAlmostEqual(
          sut._replay_memory.update_priority.call_args[0][0][4],
          129.0496,
          places=6,
      )
  
imports: import unittest
  import cntk.contrib.deeprl.tests.spaces
  import numpy
  from cntk.contrib.deeprl.agent.qlearning import QLearning
  from cntk.contrib.deeprl.agent.shared.cntk_utils import huber_loss
  from cntk.contrib.deeprl.agent.shared.replay_memory import _Transition
  from cntk.layers import Dense
  from cntk.losses import squared_error
  from cntk.ops import input_variable
label_desc: Use image node_id 10 for calling the QLearningTest obj's underlying member method code with example usage: obj.test_update_q_dqn_prioritized_replay(mock_parameters, mock_replay_memory) and returns: np