class_docstr: Agent of Cartpole env.
  
  Args:
      algorithm(parl.Algorithm): algorithm used to solve the problem.
docstr: Update model with an episode data
  
  Args:
      obs(np.float32): shape of (batch_size, obs_dim)
      act(np.int32): shape of (batch_size)
      reward(np.float32): shape of (batch_size)
      next_obs(np.float32): shape of (batch_size, obs_dim)
      terminal(np.float32): shape of (batch_size)
  
  Returns:
      loss(float)
code: def learn(self, obs, act, reward, next_obs, terminal):
      """Update model with an episode data
  
      Args:
          obs(np.float32): shape of (batch_size, obs_dim)
          act(np.int32): shape of (batch_size)
          reward(np.float32): shape of (batch_size)
          next_obs(np.float32): shape of (batch_size, obs_dim)
          terminal(np.float32): shape of (batch_size)
  
      Returns:
          loss(float)
  
      """
      if self.global_step % self.update_target_steps == 0:
          self.alg.sync_target()
      self.global_step += 1
  
      act = np.expand_dims(act, axis=-1)
      reward = np.expand_dims(reward, axis=-1)
      terminal = np.expand_dims(terminal, axis=-1)
  
      obs = paddle.to_tensor(obs, dtype="float32")
      act = paddle.to_tensor(act, dtype="int32")
      reward = paddle.to_tensor(reward, dtype="float32")
      next_obs = paddle.to_tensor(next_obs, dtype="float32")
      terminal = paddle.to_tensor(terminal, dtype="float32")
      loss = self.alg.learn(obs, act, reward, next_obs, terminal)
      return float(loss)
  
file_path: PARL/examples/DQN/cartpole_agent.py
imports: import parl
  import paddle
  import numpy
label_desc: Use image node_id 4 for calling the CartpoleAgent obj's underlying member method code with example usage: obj.learn(obs, act, reward, next_obs, terminal) and returns: float