class_docstr: Soft Actor-Critic (SAC).
  
  See https://arxiv.org/abs/1812.05905
  
  Args:
      policy (Policy): Policy.
      q_func1 (Link): First Q-function that takes state-action pairs as input
          and outputs predicted Q-values.
      q_func2 (Link): 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 `chainerrl.misc.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 (Optimizer or None): Optimizer used to optimize
          the temperature. 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.
docstr: Compute loss for a given Q-function.
code: def update_q_func(self, batch):
      """Compute loss for a given Q-function."""
  
      batch_next_state = batch["next_state"]
      batch_rewards = batch["reward"]
      batch_terminal = batch["is_state_terminal"]
      batch_state = batch["state"]
      batch_actions = batch["action"]
      batch_discount = batch["discount"]
  
      with chainer.no_backprop_mode(), chainer.using_config(
          "train", False
      ):
          next_action_distrib = self.policy(batch_next_state)
          (
              next_actions,
              next_log_prob,
          ) = next_action_distrib.sample_with_log_prob()
          next_q1 = self.target_q_func1(batch_next_state, next_actions)
          next_q2 = self.target_q_func2(batch_next_state, next_actions)
          next_q = F.minimum(next_q1, next_q2)
          entropy_term = self.temperature * next_log_prob[..., None]
          assert next_q.shape == entropy_term.shape
  
          target_q = batch_rewards + batch_discount * (
              1.0 - batch_terminal
          ) * F.flatten(next_q - entropy_term)
  
      predict_q1 = F.flatten(self.q_func1(batch_state, batch_actions))
      predict_q2 = F.flatten(self.q_func2(batch_state, batch_actions))
  
      loss1 = 0.5 * F.mean_squared_error(target_q, predict_q1)
      loss2 = 0.5 * F.mean_squared_error(target_q, predict_q2)
  
      # Update stats
      self.q1_record.extend(cuda.to_cpu(predict_q1.array))
      self.q2_record.extend(cuda.to_cpu(predict_q2.array))
      self.q_func1_loss_record.append(float(loss1.array))
      self.q_func2_loss_record.append(float(loss2.array))
  
      self.q_func1_optimizer.update(lambda: loss1)
      self.q_func2_optimizer.update(lambda: loss2)
  
imports: import collections
  import copy
  from logging import getLogger
  import chainer
  from chainer import cuda
  import chainer.functions
  import numpy
  from chainerrl.agent import AttributeSavingMixin
  from chainerrl.agent import BatchAgent
  from chainerrl.misc.batch_states import batch_states
  from chainerrl.misc.copy_param import synchronize_parameters
  from chainerrl.replay_buffer import batch_experiences
  from chainerrl.replay_buffer import ReplayUpdater
label_desc: Use image node_id 4 for calling the SoftActorCritic obj's underlying member method code with example usage: obj.update_q_func(batch) without return types