docstr: COMA algorithm
  
  Args:
      model (parl.Model): forward network of actor and critic.
      n_actions (int): action dim for each agent
      n_agents (int): agents number
      grad_norm_clip (int or float): gradient clip, prevent gradient explosion
      actor_lr (float): actor network learning rate
      critic_lr (float): critic network learning rate
      gamma (float):  discounted factor for reward computation
      td_lambda (float): lambda of td-lambda return
docstr_tok: ["COMA","algorithm","Args",":","model","(","parl.Model",")",":","forward","network","of","actor","and","critic",".","n_actions","(","int",")",":","action","dim","for","each","agent","n_agents","(","int",")",":","agents","number","grad_norm_clip","(","int","or","float",")",":","gradient","clip",",","prevent","gradient","explosion","actor_lr","(","float",")",":","actor","network","learning","rate","critic_lr","(","float",")",":","critic","network","learning","rate","gamma","(","float",")",":","discounted","factor","for","reward","computation","td_lambda","(","float",")",":","lambda","of","td-lambda","return"]
code: def __init__(
      self,
      model,
      n_actions,
      n_agents,
      grad_norm_clip=None,
      actor_lr=None,
      critic_lr=None,
      gamma=None,
      td_lambda=None,
  ):
      """COMA algorithm
  
      Args:
          model (parl.Model): forward network of actor and critic.
          n_actions (int): action dim for each agent
          n_agents (int): agents number
          grad_norm_clip (int or float): gradient clip, prevent gradient explosion
          actor_lr (float): actor network learning rate
          critic_lr (float): critic network learning rate
          gamma (float):  discounted factor for reward computation
          td_lambda (float): lambda of td-lambda return
      """
      # 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(n_actions, int)
      assert isinstance(n_agents, int)
      assert isinstance(grad_norm_clip, int) or isinstance(
          grad_norm_clip, float
      )
      assert isinstance(actor_lr, float)
      assert isinstance(critic_lr, float)
      assert isinstance(gamma, float)
      assert isinstance(td_lambda, float)
  
      self.device = torch.device(
          "cuda" if torch.cuda.is_available() else "cpu"
      )
      self.n_actions = n_actions
      self.n_agents = n_agents
      self.grad_norm_clip = grad_norm_clip
      self.actor_lr = actor_lr
      self.critic_lr = critic_lr
      self.gamma = gamma
      self.td_lambda = td_lambda
  
      self.model = model.to(self.device)
      self.target_model = deepcopy(model).to(self.device)
  
      self.sync_target()
  
      self.actor_parameters = list(self.model.get_actor_params())
      self.critic_parameters = list(self.model.get_critic_params())
  
      self.critic_optimizer = torch.optim.RMSprop(
          self.critic_parameters, lr=self.critic_lr
      )
      self.actor_optimizer = torch.optim.RMSprop(
          self.actor_parameters, lr=self.actor_lr
      )
  
      self.train_rnn_h = None
  
file_path: PARL/parl/algorithms/torch/coma.py
imports: import torch
  import os
  from copy import deepcopy
  import parl
  from parl.utils.utils import check_model_method
  import numpy
label_desc: Use image node_id 1 to create a new COMA object from inherited base classes: parl with example: obj = COMA(model, n_actions, n_agents, grad_norm_clip, actor_lr, critic_lr, gamma, td_lambda)