docstr: Args:
      obs: An float32 tensor of shape ([B] + observation_space).
           E.g. [B, C, H, W] in atari.
      actions: An int64 tensor of shape [B].
      advantages: A float32 tensor of shape [B].
      target_values: A float32 tensor of shape [B].
      learning_rate: float scalar of learning rate.
      entropy_coeff: float scalar of entropy coefficient.
docstr_tok: ["Args",":","obs",":","An","float32","tensor","of","shape","(","[","B","]","+","observation_space",")",".","E.g",".","[","B",",","C",",","H",",","W","]","in","atari",".","actions",":","An","int64","tensor","of","shape","[","B","]",".","advantages",":","A","float32","tensor","of","shape","[","B","]",".","target_values",":","A","float32","tensor","of","shape","[","B","]",".","learning_rate",":","float","scalar","of","learning","rate",".","entropy_coeff",":","float","scalar","of","entropy","coefficient","."]
code: def learn(
      self,
      obs,
      actions,
      advantages,
      target_values,
      learning_rate,
      entropy_coeff,
  ):
      """
      Args:
          obs: An float32 tensor of shape ([B] + observation_space).
               E.g. [B, C, H, W] in atari.
          actions: An int64 tensor of shape [B].
          advantages: A float32 tensor of shape [B].
          target_values: A float32 tensor of shape [B].
          learning_rate: float scalar of learning rate.
          entropy_coeff: float scalar of entropy coefficient.
      """
      logits = self.model.policy(obs)
      policy_distribution = CategoricalDistribution(logits)
      actions_log_probs = policy_distribution.logp(actions)
  
      # The policy gradient loss
      pi_loss = -1.0 * layers.reduce_sum(actions_log_probs * advantages)
  
      # The value function loss
      values = self.model.value(obs)
      delta = values - target_values
      vf_loss = 0.5 * layers.reduce_sum(layers.square(delta))
  
      # The entropy loss (We want to maximize entropy, so entropy_ceoff < 0)
      policy_entropy = policy_distribution.entropy()
      entropy = layers.reduce_sum(policy_entropy)
  
      total_loss = (
          pi_loss
          + vf_loss * self.vf_loss_coeff
          + entropy * entropy_coeff
      )
  
      reduced_total_loss = layers.reduce_sum(total_loss)
  
      fluid.clip.set_gradient_clip(
          clip=fluid.clip.GradientClipByGlobalNorm(clip_norm=40.0)
      )
  
      optimizer = fluid.optimizer.AdamOptimizer(learning_rate)
      optimizer.minimize(reduced_total_loss)
  
      return reduced_total_loss, pi_loss, vf_loss, entropy
  
file_path: PARL/parl/algorithms/fluid/a3c.py
imports: import warnings
  import paddle.fluid
  from parl.core.fluid import layers
  from parl.core.fluid.algorithm import Algorithm
  from parl.core.fluid.policy_distribution import CategoricalDistribution
label_desc: Use image node_id 2 for calling the A3C obj's underlying member method code with example usage: obj.learn(obs, actions, advantages, target_values, learning_rate, entropy_coeff) and returns: reduced_total_loss,  pi_loss,  vf_loss,  entropy