docstr: 用policy gradient 算法更新policy model
          
code: def learn(self, obs, action, reward):
      """用policy gradient 算法更新policy model"""
      prob = self.model(obs)  # 获取输出动作概率
      # log_prob = Categorical(prob).log_prob(action) # 交叉熵
      # loss = paddle.mean(-1 * log_prob * reward)
      action_onehot = paddle.squeeze(
          F.one_hot(action, num_classes=prob.shape[1]), axis=1
      )
      log_prob = paddle.sum(paddle.log(prob) * action_onehot, axis=-1)
      reward = paddle.squeeze(reward, axis=1)
      loss = paddle.mean(-1 * log_prob * reward)
  
      self.optimizer.clear_grad()
      loss.backward()
      self.optimizer.step()
      return loss
  
file_path: PARL/examples/tutorials/parl2_dygraph/lesson4/policy_gradient/algorithm.py
imports: import parl
  import paddle
  from paddle.distribution import Categorical
  import paddle.nn.functional
label_desc: Use image node_id 3 for calling the PolicyGradient obj's underlying member method code with example usage: obj.learn(obs, action, reward) and returns: loss