docstr: use the policy model to sample actions
  
  Args:
      obs (paddle tensor): observation, shape([B] + shape of obs_n[agent_index])
      use_target_model (bool): use target_model or not
  
  Returns:
      act (paddle tensor): action, shape([B] + shape of act_n[agent_index]),
          noted that in the discrete case we take the argmax along the last axis as action
docstr_tok: ["use","the","policy","model","to","sample","actions","Args",":","obs","(","paddle","tensor",")",":","observation",",","shape","(","[","B","]","+","shape","of","obs_n","[","agent_index","]",")","use_target_model","(","bool",")",":","use","target_model","or","not","Returns",":","act","(","paddle","tensor",")",":","action",",","shape","(","[","B","]","+","shape","of","act_n","[","agent_index","]",")",",","noted","that","in","the","discrete","case","we","take","the","argmax","along","the","last","axis","as","action"]
code: def sample(self, obs, use_target_model=False):
      """use the policy model to sample actions
  
      Args:
          obs (paddle tensor): observation, shape([B] + shape of obs_n[agent_index])
          use_target_model (bool): use target_model or not
  
      Returns:
          act (paddle tensor): action, shape([B] + shape of act_n[agent_index]),
              noted that in the discrete case we take the argmax along the last axis as action
      """
      if use_target_model:
          policy = self.target_model.policy(obs)
      else:
          policy = self.model.policy(obs)
  
      # add noise for action exploration
      if self.continuous_actions:
          mean, std = policy[0], paddle.exp(policy[1])
          mean_shape = paddle.to_tensor(mean.shape, dtype="int64")
          random_normal = paddle.normal(shape=mean_shape)
          action = mean + std * random_normal
          action = paddle.tanh(action)
      else:
          eps = 1e-4
          logits_shape = paddle.to_tensor(policy.shape, dtype="int64")
          uniform = paddle.uniform(logits_shape, min=eps, max=1.0 - eps)
          soft_uniform = paddle.log(-1.0 * paddle.log(uniform))
          action = F.softmax(policy - soft_uniform, axis=-1)
      return action
  
file_path: PARL/parl/algorithms/paddle/maddpg.py
imports: import parl
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from parl.utils.utils import check_model_method
  from copy import deepcopy
label_desc: Use image node_id 3 for calling the MADDPG obj's underlying member method code with example usage: obj.sample(obs, use_target_model) and returns: action