docstr: MADDPG algorithm
  
  Args:
      model (parl.Model): forward network of actor and critic.
                          The function get_actor_params() of model should be implemented.
      agent_index (int): index of agent, in multiagent env
      act_space (list): action_space, gym space
      gamma (float): discounted factor for reward computation.
      tau (float): decay coefficient when updating the weights of self.target_model with self.model
      critic_lr (float): learning rate of the critic model
      actor_lr (float): learning rate of the actor model
docstr_tok: ["MADDPG","algorithm","Args",":","model","(","parl.Model",")",":","forward","network","of","actor","and","critic",".","The","function","get_actor_params","(",")","of","model","should","be","implemented",".","agent_index","(","int",")",":","index","of","agent",",","in","multiagent","env","act_space","(","list",")",":","action_space",",","gym","space","gamma","(","float",")",":","discounted","factor","for","reward","computation",".","tau","(","float",")",":","decay","coefficient","when","updating","the","weights","of","self.target_model","with","self.model","critic_lr","(","float",")",":","learning","rate","of","the","critic","model","actor_lr","(","float",")",":","learning","rate","of","the","actor","model"]
code: def __init__(
      self,
      model,
      agent_index=None,
      act_space=None,
      gamma=None,
      tau=None,
      actor_lr=None,
      critic_lr=None,
  ):
      """MADDPG algorithm
  
      Args:
          model (parl.Model): forward network of actor and critic.
                              The function get_actor_params() of model should be implemented.
          agent_index (int): index of agent, in multiagent env
          act_space (list): action_space, gym space
          gamma (float): discounted factor for reward computation.
          tau (float): decay coefficient when updating the weights of self.target_model with self.model
          critic_lr (float): learning rate of the critic model
          actor_lr (float): learning rate of the actor model
      """
      # checks
      check_model_method(model, "value", self.__class__.__name__)
      check_model_method(model, "policy", self.__class__.__name__)
      check_model_method(
          model, "get_actor_params", self.__class__.__name__
      )
      check_model_method(
          model, "get_critic_params", self.__class__.__name__
      )
      assert isinstance(agent_index, int)
      assert isinstance(act_space, list)
      assert isinstance(gamma, float)
      assert isinstance(tau, float)
      assert isinstance(actor_lr, float)
      assert isinstance(critic_lr, float)
  
      self.continuous_actions = False
      if not len(act_space) == 0 and hasattr(act_space[0], "high"):
          self.continuous_actions = True
  
      self.agent_index = agent_index
      self.act_space = act_space
      self.gamma = gamma
      self.tau = tau
      self.actor_lr = actor_lr
      self.critic_lr = critic_lr
  
      self.model = model
      self.target_model = deepcopy(model)
      self.sync_target(0)
  
      self.actor_optimizer = paddle.optimizer.Adam(
          learning_rate=self.actor_lr,
          parameters=self.model.get_actor_params(),
          grad_clip=nn.ClipGradByNorm(clip_norm=0.5),
      )
      self.critic_optimizer = paddle.optimizer.Adam(
          learning_rate=self.critic_lr,
          parameters=self.model.get_critic_params(),
          grad_clip=nn.ClipGradByNorm(clip_norm=0.5),
      )
  
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 1 to create a new MADDPG object from inherited base classes: parl with example: obj = MADDPG(model, agent_index, act_space, gamma, tau, actor_lr, critic_lr)