class_docstr: Unit tests for QLearning.
class_docstr_tok: ["Unit","tests","for","QLearning","."]
code: def test_update_q_dqn(self, mock_parameters, mock_replay_memory):
      self._setup_parameters(mock_parameters.return_value)
      self._setup_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)
  
      sut._q.eval = MagicMock(
          return_value=np.array([[[0.2, 0.1]]], np.float32)
      )
      sut._target_q.eval = MagicMock(
          return_value=np.array([[[0.3, 0.4]]], np.float32)
      )
      sut._trainer = MagicMock()
  
      sut._update_q_periodically()
  
      np.testing.assert_array_equal(
          sut._trainer.train_minibatch.call_args[0][0][
              sut._input_variables
          ],
          [np.array([0.1], np.float32)],
      )
      # 10 (reward) + 0.9 (gamma) x 0.4 (max q_target) -> update action 0
      np.testing.assert_array_equal(
          sut._trainer.train_minibatch.call_args[0][0][
              sut._output_variables
          ],
          [np.array([10.36, 0.1], np.float32)],
      )
  
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 9 for calling the QLearningTest obj's underlying member method code with example usage: obj.test_update_q_dqn(mock_parameters, mock_replay_memory) without return types