class_docstr: A CQL-SAC Agent based on the SAC Agent.
docstr: Computes actor_loss equivalent to the SAC actor_loss.
  
  Uses behavioral cloning for the first `self._num_bc_steps` of training.
  
  Args:
    time_steps: A batch of timesteps.
    actions: A batch of actions.
    weights: Optional scalar or elementwise (per-batch-entry) importance
      weights.
    training: Whether training should be applied.
  
  Returns:
    actor_loss: A scalar actor loss.
docstr_tok: ["Computes","actor_loss","equivalent","to","the","SAC","actor_loss",".","Uses","behavioral","cloning","for","the","first","`","self._num_bc_steps","`","of","training",".","Args",":","time_steps",":","A","batch","of","timesteps",".","actions",":","A","batch","of","actions",".","weights",":","Optional","scalar","or","elementwise","(","per-batch-entry",")","importance","weights",".","training",":","Whether","training","should","be","applied",".","Returns",":","actor_loss",":","A","scalar","actor","loss","."]
code: def actor_loss(
      self,
      time_steps: ts.TimeStep,
      actions: types.Tensor,
      weights: Optional[types.Tensor] = None,
      training: Optional[bool] = True,
  ) -> types.Tensor:
      """Computes actor_loss equivalent to the SAC actor_loss.
  
      Uses behavioral cloning for the first `self._num_bc_steps` of training.
  
      Args:
        time_steps: A batch of timesteps.
        actions: A batch of actions.
        weights: Optional scalar or elementwise (per-batch-entry) importance
          weights.
        training: Whether training should be applied.
  
      Returns:
        actor_loss: A scalar actor loss.
      """
      with tf.name_scope("actor_loss"):
          nest_utils.assert_same_structure(
              time_steps, self.time_step_spec
          )
  
          sampled_actions, sampled_log_pi = self._actions_and_log_probs(
              time_steps, training=training
          )
  
          # Behavioral cloning: train the policy to reproduce actions from
          # the dataset.
          if self.train_step_counter < self._num_bc_steps:
              distribution, _ = self._actor_network(
                  time_steps.observation, time_steps.step_type, ()
              )
              actor_log_prob = distribution.log_prob(actions)
              actor_loss = (
                  tf.exp(self._log_alpha) * sampled_log_pi
                  - actor_log_prob
              )
              target_q_values = tf.zeros(tf.shape(sampled_log_pi))
          else:
              target_input = (time_steps.observation, sampled_actions)
              target_q_values1, _ = self._critic_network_1(
                  target_input, time_steps.step_type, training=False
              )
              target_q_values2, _ = self._critic_network_2(
                  target_input, time_steps.step_type, training=False
              )
              target_q_values = tf.minimum(
                  target_q_values1, target_q_values2
              )
              actor_loss = (
                  tf.exp(self._log_alpha) * sampled_log_pi
                  - target_q_values
              )
  
          if actor_loss.shape.rank > 1:
              # Sum over the time dimension.
              actor_loss = tf.reduce_sum(
                  actor_loss, axis=range(1, actor_loss.shape.rank)
              )
          reg_loss = (
              self._actor_network.losses
              if self._actor_network
              else None
          )
          agg_loss = common.aggregate_losses(
              per_example_loss=actor_loss,
              sample_weight=weights,
              regularization_loss=reg_loss,
          )
          actor_loss = agg_loss.total_loss
          self._actor_loss_debug_summaries(
              actor_loss,
              sampled_actions,
              sampled_log_pi,
              target_q_values,
              time_steps,
          )
  
          return actor_loss
  
imports: from typing import Callable, Dict, NamedTuple, Optional, Text, Tuple, Union
  import gin
  import tensorflow
  import tensorflow_probability
  from tf_agents.agents import tf_agent
  from tf_agents.agents.sac import sac_agent
  from tf_agents.networks import network
  from tf_agents.policies import actor_policy
  from tf_agents.policies import tf_policy
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import object_identity
label_desc: Use image node_id 11 for calling the CqlSacAgent obj's underlying member method code with example usage: obj.actor_loss(time_steps, actions, weights, training) and returns: actor_loss