class_docstr: A DDPG Agent.
docstr: Computes the actor_loss for DDPG training.
  
  Args:
    time_steps: A batch of timesteps.
    weights: Optional scalar or element-wise (per-batch-entry) importance
      weights.
    training: Whether this loss is being used for training.
  
  Returns:
    actor_loss: A scalar actor loss.
docstr_tok: ["Computes","the","actor_loss","for","DDPG","training",".","Args",":","time_steps",":","A","batch","of","timesteps",".","weights",":","Optional","scalar","or","element-wise","(","per-batch-entry",")","importance","weights",".","training",":","Whether","this","loss","is","being","used","for","training",".","Returns",":","actor_loss",":","A","scalar","actor","loss","."]
code: def actor_loss(
      self,
      time_steps: ts.TimeStep,
      weights: Optional[types.Tensor] = None,
      training: bool = False,
  ) -> types.Tensor:
      """Computes the actor_loss for DDPG training.
  
      Args:
        time_steps: A batch of timesteps.
        weights: Optional scalar or element-wise (per-batch-entry) importance
          weights.
        training: Whether this loss is being used for training.
  
      Returns:
        actor_loss: A scalar actor loss.
      """
      # TODO(b/124383618): Add an action norm regularizer.
      with tf.name_scope("actor_loss"):
          actions, _ = self._actor_network(
              time_steps.observation,
              step_type=time_steps.step_type,
              training=training,
          )
          with tf.GradientTape(watch_accessed_variables=False) as tape:
              tape.watch(actions)
              q_values, _ = self._critic_network(
                  (time_steps.observation, actions),
                  step_type=time_steps.step_type,
                  training=False,
              )
              actions = tf.nest.flatten(actions)
  
          dqdas = tape.gradient([q_values], actions)
  
          actor_losses = []
          for dqda, action in zip(dqdas, actions):
              if self._dqda_clipping is not None:
                  dqda = tf.clip_by_value(
                      dqda,
                      -1 * self._dqda_clipping,
                      self._dqda_clipping,
                  )
              loss = common.element_wise_squared_loss(
                  tf.stop_gradient(dqda + action), action
              )
              if nest_utils.is_batched_nested_tensors(
                  time_steps, self.time_step_spec, num_outer_dims=2
              ):
                  # Sum over the time dimension.
                  loss = tf.reduce_sum(loss, axis=1)
              if weights is not None:
                  loss *= weights
              loss = tf.reduce_mean(loss)
              actor_losses.append(loss)
  
          actor_loss = tf.add_n(actor_losses)
  
          with tf.name_scope("Losses/"):
              tf.compat.v2.summary.scalar(
                  name="actor_loss",
                  data=actor_loss,
                  step=self.train_step_counter,
              )
  
      return actor_loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Optional, Text
  import gin
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.networks import network
  from tf_agents.policies import actor_policy
  from tf_agents.policies import ou_noise_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 eager_utils
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 8 for calling the DdpgAgent obj's underlying member method code with example usage: obj.actor_loss(time_steps, weights, training) and returns: actor_loss