class_docstr: Soft Actor-Critic (SAC).
  
  See https://arxiv.org/abs/1812.05905
  
  Args:
      policy (Policy): Policy.
      q_func1 (Module): First Q-function that takes state-action pairs as input
          and outputs predicted Q-values.
      q_func2 (Module): Second Q-function that takes state-action pairs as
          input and outputs predicted Q-values.
      policy_optimizer (Optimizer): Optimizer setup with the policy
      q_func1_optimizer (Optimizer): Optimizer setup with the first
          Q-function.
      q_func2_optimizer (Optimizer): Optimizer setup with the second
          Q-function.
      replay_buffer (ReplayBuffer): Replay buffer
      gamma (float): Discount factor
      gpu (int): GPU device id if not None nor negative.
      replay_start_size (int): if the replay buffer's size is less than
          replay_start_size, skip update
      minibatch_size (int): Minibatch size
      update_interval (int): Model update interval in step
      phi (callable): Feature extractor applied to observations
      soft_update_tau (float): Tau of soft target update.
      logger (Logger): Logger used
      batch_states (callable): method which makes a batch of observations.
          default is `pfrl.utils.batch_states.batch_states`
      burnin_action_func (callable or None): If not None, this callable
          object is used to select actions before the model is updated
          one or more times during training.
      initial_temperature (float): Initial temperature value. If
          `entropy_target` is set to None, the temperature is fixed to it.
      entropy_target (float or None): If set to a float, the temperature is
          adjusted during training to match the policy's entropy to it.
      temperature_optimizer_lr (float): Learning rate of the temperature
          optimizer. If set to None, Adam with default hyperparameters
          is used.
      act_deterministically (bool): If set to True, choose most probable
          actions in the act method instead of sampling from distributions.
class_docstr_tok: ["Soft","Actor-Critic","(","SAC",")",".","See","https",":","\/\/arxiv.org\/abs\/1812.05905","Args",":","policy","(","Policy",")",":","Policy",".","q_func1","(","Module",")",":","First","Q-function","that","takes","state-action","pairs","as","input","and","outputs","predicted","Q-values",".","q_func2","(","Module",")",":","Second","Q-function","that","takes","state-action","pairs","as","input","and","outputs","predicted","Q-values",".","policy_optimizer","(","Optimizer",")",":","Optimizer","setup","with","the","policy","q_func1_optimizer","(","Optimizer",")",":","Optimizer","setup","with","the","first","Q-function",".","q_func2_optimizer","(","Optimizer",")",":","Optimizer","setup","with","the","second","Q-function",".","replay_buffer","(","ReplayBuffer",")",":","Replay","buffer","gamma","(","float",")",":","Discount","factor","gpu","(","int",")",":","GPU","device","id","if","not","None","nor","negative",".","replay_start_size","(","int",")",":","if","the","replay","buffer","'s","size","is","less","than","replay_start_size",",","skip","update","minibatch_size","(","int",")",":","Minibatch","size","update_interval","(","int",")",":","Model","update","interval","in","step","phi","(","callable",")",":","Feature","extractor","applied","to","observations","soft_update_tau","(","float",")",":","Tau","of","soft","target","update",".","logger","(","Logger",")",":","Logger","used","batch_states","(","callable",")",":","method","which","makes","a","batch","of","observations",".","default","is","`","pfrl.utils.batch_states.batch_states","`","burnin_action_func","(","callable","or","None",")",":","If","not","None",",","this","callable","object","is","used","to","select","actions","before","the","model","is","updated","one","or","more","times","during","training",".","initial_temperature","(","float",")",":","Initial","temperature","value",".","If","`","entropy_target","`","is","set","to","None",",","the","temperature","is","fixed","to","it",".","entropy_target","(","float","or","None",")",":","If","set","to","a","float",",","the","temperature","is","adjusted","during","training","to","match","the","policy","'s","entropy","to","it",".","temperature_optimizer_lr","(","float",")",":","Learning","rate","of","the","temperature","optimizer",".","If","set","to","None",",","Adam","with","default","hyperparameters","is","used",".","act_deterministically","(","bool",")",":","If","set","to","True",",","choose","most","probable","actions","in","the","act","method","instead","of","sampling","from","distributions","."]
code: def __init__(
      self,
      policy,
      q_func1,
      q_func2,
      policy_optimizer,
      q_func1_optimizer,
      q_func2_optimizer,
      replay_buffer,
      gamma,
      gpu=None,
      replay_start_size=10000,
      minibatch_size=100,
      update_interval=1,
      phi=lambda x: x,
      soft_update_tau=5e-3,
      max_grad_norm=None,
      logger=getLogger(__name__),
      batch_states=batch_states,
      burnin_action_func=None,
      initial_temperature=1.0,
      entropy_target=None,
      temperature_optimizer_lr=None,
      act_deterministically=True,
  ):
      self.policy = policy
      self.q_func1 = q_func1
      self.q_func2 = q_func2
  
      if gpu is not None and gpu >= 0:
          assert torch.cuda.is_available()
          self.device = torch.device("cuda:{}".format(gpu))
          self.policy.to(self.device)
          self.q_func1.to(self.device)
          self.q_func2.to(self.device)
      else:
          self.device = torch.device("cpu")
  
      self.replay_buffer = replay_buffer
      self.gamma = gamma
      self.gpu = gpu
      self.phi = phi
      self.soft_update_tau = soft_update_tau
      self.logger = logger
      self.policy_optimizer = policy_optimizer
      self.q_func1_optimizer = q_func1_optimizer
      self.q_func2_optimizer = q_func2_optimizer
      self.replay_updater = ReplayUpdater(
          replay_buffer=replay_buffer,
          update_func=self.update,
          batchsize=minibatch_size,
          n_times_update=1,
          replay_start_size=replay_start_size,
          update_interval=update_interval,
          episodic_update=False,
      )
      self.max_grad_norm = max_grad_norm
      self.batch_states = batch_states
      self.burnin_action_func = burnin_action_func
      self.initial_temperature = initial_temperature
      self.entropy_target = entropy_target
      if self.entropy_target is not None:
          self.temperature_holder = TemperatureHolder(
              initial_log_temperature=np.log(initial_temperature)
          )
          if temperature_optimizer_lr is not None:
              self.temperature_optimizer = torch.optim.Adam(
                  self.temperature_holder.parameters(),
                  lr=temperature_optimizer_lr,
              )
          else:
              self.temperature_optimizer = torch.optim.Adam(
                  self.temperature_holder.parameters()
              )
          if gpu is not None and gpu >= 0:
              self.temperature_holder.to(self.device)
      else:
          self.temperature_holder = None
          self.temperature_optimizer = None
      self.act_deterministically = act_deterministically
  
      self.t = 0
  
      # Target model
      self.target_q_func1 = (
          copy.deepcopy(self.q_func1).eval().requires_grad_(False)
      )
      self.target_q_func2 = (
          copy.deepcopy(self.q_func2).eval().requires_grad_(False)
      )
  
      # Statistics
      self.q1_record = collections.deque(maxlen=1000)
      self.q2_record = collections.deque(maxlen=1000)
      self.entropy_record = collections.deque(maxlen=1000)
      self.q_func1_loss_record = collections.deque(maxlen=100)
      self.q_func2_loss_record = collections.deque(maxlen=100)
      self.n_policy_updates = 0
  
imports: import collections
  import copy
  from logging import getLogger
  import numpy
  import torch
  from torch import nn
  from torch.nn import functional
  import pfrl
  from pfrl.agent import AttributeSavingMixin, BatchAgent
  from pfrl.replay_buffer import ReplayUpdater, batch_experiences
  from pfrl.utils import clip_l2_grad_norm_
  from pfrl.utils.batch_states import batch_states
  from pfrl.utils.copy_param import synchronize_parameters
  from pfrl.utils.mode_of_distribution import mode_of_distribution
label_desc: Use image node_id 1 to create a new SoftActorCritic object from inherited base classes: AttributeSavingMixin, BatchAgent with example: obj = SoftActorCritic(policy, q_func1, q_func2, policy_optimizer, q_func1_optimizer, q_func2_optimizer, replay_buffer, gamma, gpu, replay_start_size, minibatch_size, update_interval, phi, soft_update_tau, max_grad_norm, logger, batch_states, burnin_action_func, initial_temperature, entropy_target, temperature_optimizer_lr, act_deterministically)