class_docstr: Soft Actor-Critic trainer as described in https://arxiv.org/pdf/1801.01290
  
  The actor is assumed to implement reparameterization trick.
docstr: Args:
      actor_network: states -> actions, trained to maximize soft value,
          which is value + policy entropy.
      q1_network: states, action -> q-value
      q2_network (optional): double q-learning to stabilize training
          from overestimation bias
      value_network (optional): states -> value of state under actor
      # alpha in the paper; controlling explore & exploit
      backprop_through_log_prob: This is mostly for backward compatibility issue;
          we used to have a bug that does this and it yields a better result in
          some cases
      # TODO: finish
docstr_tok: ["Args",":","actor_network",":","states","-",">","actions",",","trained","to","maximize","soft","value",",","which","is","value","+","policy","entropy",".","q1_network",":","states",",","action","-",">","q-value","q2_network","(","optional",")",":","double","q-learning","to","stabilize","training","from","overestimation","bias","value_network","(","optional",")",":","states","-",">","value","of","state","under","actor","#","alpha","in","the","paper",";","controlling","explore","&","exploit","backprop_through_log_prob",":","This","is","mostly","for","backward","compatibility","issue",";","we","used","to","have","a","bug","that","does","this","and","it","yields","a","better","result","in","some","cases","#","TODO",":","finish"]
code: def __init__(
      self,
      actor_network,
      q1_network,
      q2_network=None,
      value_network=None,
      # Start SACTrainerParameters
      rl: RLParameters = field(
          default_factory=RLParameters
      ),  # noqa: B008
      q_network_optimizer: Optimizer__Union = field(  # noqa: B008
          default_factory=Optimizer__Union.default
      ),
      value_network_optimizer: Optimizer__Union = field(  # noqa: B008
          default_factory=Optimizer__Union.default
      ),
      actor_network_optimizer: Optimizer__Union = field(  # noqa: B008
          default_factory=Optimizer__Union.default
      ),
      alpha_optimizer: Optional[Optimizer__Union] = field(  # noqa: B008
          default_factory=Optimizer__Union.default
      ),
      minibatch_size: int = 1024,
      entropy_temperature: float = 0.01,
      logged_action_uniform_prior: bool = True,
      target_entropy: float = -1.0,
      action_embedding_kld_weight: Optional[float] = None,
      apply_kld_on_mean: bool = False,
      action_embedding_mean: Optional[List[float]] = None,
      action_embedding_variance: Optional[List[float]] = None,
      crr_config: Optional[CRRWeightFn] = None,
      backprop_through_log_prob: bool = True,
  ) -> None:
      """
      Args:
          actor_network: states -> actions, trained to maximize soft value,
              which is value + policy entropy.
          q1_network: states, action -> q-value
          q2_network (optional): double q-learning to stabilize training
              from overestimation bias
          value_network (optional): states -> value of state under actor
          # alpha in the paper; controlling explore & exploit
          backprop_through_log_prob: This is mostly for backward compatibility issue;
              we used to have a bug that does this and it yields a better result in
              some cases
          # TODO: finish
      """
      super().__init__()
      self.rl_parameters = rl
      self.q1_network = q1_network
      self.q2_network = q2_network
      self.q_network_optimizer = q_network_optimizer
  
      self.value_network = value_network
      self.value_network_optimizer = value_network_optimizer
      if self.value_network is not None:
          self.value_network_target = copy.deepcopy(self.value_network)
      else:
          self.q1_network_target = copy.deepcopy(self.q1_network)
          self.q2_network_target = copy.deepcopy(self.q2_network)
  
      self.actor_network = actor_network
      self.actor_network_optimizer = actor_network_optimizer
      self.entropy_temperature = entropy_temperature
  
      self.alpha_optimizer = alpha_optimizer
      if alpha_optimizer is not None:
          self.target_entropy = target_entropy
          self.log_alpha = torch.nn.Parameter(
              torch.tensor([np.log(self.entropy_temperature)])
          )
  
      self.logged_action_uniform_prior = logged_action_uniform_prior
  
      self.add_kld_to_loss = bool(action_embedding_kld_weight)
      self.apply_kld_on_mean = apply_kld_on_mean
  
      if self.add_kld_to_loss:
          self.kld_weight = action_embedding_kld_weight
          # Calling register_buffer so that the tensors got moved to the right device
          self.register_buffer("action_emb_mean", None)
          self.register_buffer("action_emb_variance", None)
          # Assigning the values here instead of above so that typechecker wouldn't complain
          self.action_emb_mean = torch.tensor(action_embedding_mean)
          self.action_emb_variance = torch.tensor(
              action_embedding_variance
          )
  
      self.crr_config = crr_config
      if crr_config:
          assert self.value_network is not None
  
      self.backprop_through_log_prob = backprop_through_log_prob
  
imports: import copy
  import logging
  from typing import List, Optional
  import numpy
  import reagent.core.types
  import torch
  import torch.nn.functional
  from reagent.core.configuration import resolve_defaults
  from reagent.core.dataclasses import dataclass, field
  from reagent.core.parameters import RLParameters
  from reagent.models.actor import LOG_PROB_MAX, LOG_PROB_MIN
  from reagent.optimizer import Optimizer__Union, SoftUpdate
  from reagent.training.reagent_lightning_module import ReAgentLightningModule
  from reagent.training.rl_trainer_pytorch import RLTrainerMixin
label_desc: Use image node_id 1 to create a new SACTrainer object from inherited base classes: RLTrainerMixin, ReAgentLightningModule with example: obj = SACTrainer(actor_network, q1_network, q2_network, value_network, rl, q_network_optimizer, value_network_optimizer, actor_network_optimizer, alpha_optimizer, minibatch_size, entropy_temperature, logged_action_uniform_prior, target_entropy, action_embedding_kld_weight, apply_kld_on_mean, action_embedding_mean, action_embedding_variance, crr_config, backprop_through_log_prob)