docstr: sample batch, compute q_target and train
          
docstr_tok: ["sample","batch",",","compute","q_target","and","train"]
code: def learn(self, agents):
      """sample batch, compute q_target and train"""
      self.global_train_step += 1
  
      # only update parameter every 100 steps
      if self.global_train_step % 100 != 0:
          return 0.0
  
      if self.rpm.size() <= self.min_memory_size:
          return 0.0
  
      batch_obs_n = []
      batch_act_n = []
      batch_obs_next_n = []
  
      # sample batch
      rpm_sample_index = self.rpm.make_index(self.batch_size)
      for i in range(self.n):
          batch_obs, batch_act, _, batch_obs_next, _ = agents[
              i
          ].rpm.sample_batch_by_index(rpm_sample_index)
          batch_obs_n.append(batch_obs)
          batch_act_n.append(batch_act)
          batch_obs_next_n.append(batch_obs_next)
      _, _, batch_rew, _, batch_isOver = self.rpm.sample_batch_by_index(
          rpm_sample_index
      )
      batch_obs_n = [
          paddle.to_tensor(obs, dtype="float32") for obs in batch_obs_n
      ]
      batch_act_n = [
          paddle.to_tensor(act, dtype="float32") for act in batch_act_n
      ]
      batch_rew = paddle.to_tensor(batch_rew, dtype="float32")
      batch_isOver = paddle.to_tensor(batch_isOver, dtype="float32")
  
      # compute target q
      target_act_next_n = []
      batch_obs_next_n = [
          paddle.to_tensor(obs, dtype="float32")
          for obs in batch_obs_next_n
      ]
      for i in range(self.n):
          target_act_next = agents[i].alg.sample(
              batch_obs_next_n[i], use_target_model=True
          )
          target_act_next = target_act_next.detach()
          target_act_next_n.append(target_act_next)
      target_q_next = self.alg.Q(
          batch_obs_next_n, target_act_next_n, use_target_model=True
      )
      target_q = (
          batch_rew
          + self.alg.gamma
          * (1.0 - batch_isOver)
          * target_q_next.detach()
      )
  
      # learn
      critic_cost = self.alg.learn(batch_obs_n, batch_act_n, target_q)
      critic_cost = float(critic_cost.cpu().detach())
  
      return critic_cost
  
file_path: PARL/examples/MADDPG/simple_agent.py
imports: import parl
  import paddle
  import numpy
  from parl.utils import ReplayMemory
label_desc: Use image node_id 4 for calling the MAAgent obj's underlying member method code with example usage: obj.learn(agents) and returns: critic_cost, int, int