class_docstr: A DDPG Agent.
docstr: Computes the critic loss for DDPG training.
  
  Args:
    time_steps: A batch of timesteps.
    actions: A batch of actions.
    next_time_steps: A batch of next timesteps.
    weights: Optional scalar or element-wise (per-batch-entry) importance
      weights.
    training: Whether this loss is being used for training.
  
  Returns:
    critic_loss: A scalar critic loss.
docstr_tok: ["Computes","the","critic","loss","for","DDPG","training",".","Args",":","time_steps",":","A","batch","of","timesteps",".","actions",":","A","batch","of","actions",".","next_time_steps",":","A","batch","of","next","timesteps",".","weights",":","Optional","scalar","or","element-wise","(","per-batch-entry",")","importance","weights",".","training",":","Whether","this","loss","is","being","used","for","training",".","Returns",":","critic_loss",":","A","scalar","critic","loss","."]
code: def critic_loss(
      self,
      time_steps: ts.TimeStep,
      actions: types.NestedTensor,
      next_time_steps: ts.TimeStep,
      weights: Optional[types.Tensor] = None,
      training: bool = False,
  ) -> types.Tensor:
      """Computes the critic loss for DDPG training.
  
      Args:
        time_steps: A batch of timesteps.
        actions: A batch of actions.
        next_time_steps: A batch of next timesteps.
        weights: Optional scalar or element-wise (per-batch-entry) importance
          weights.
        training: Whether this loss is being used for training.
  
      Returns:
        critic_loss: A scalar critic loss.
      """
      with tf.name_scope("critic_loss"):
          target_actions, _ = self._target_actor_network(
              next_time_steps.observation,
              step_type=next_time_steps.step_type,
              training=False,
          )
          target_critic_net_input = (
              next_time_steps.observation,
              target_actions,
          )
          target_q_values, _ = self._target_critic_network(
              target_critic_net_input,
              step_type=next_time_steps.step_type,
              training=False,
          )
  
          td_targets = tf.stop_gradient(
              self._reward_scale_factor * next_time_steps.reward
              + self._gamma * next_time_steps.discount * target_q_values
          )
  
          critic_net_input = (time_steps.observation, actions)
          q_values, _ = self._critic_network(
              critic_net_input,
              step_type=time_steps.step_type,
              training=training,
          )
  
          critic_loss = self._td_errors_loss_fn(td_targets, q_values)
          if nest_utils.is_batched_nested_tensors(
              time_steps, self.time_step_spec, num_outer_dims=2
          ):
              # Do a sum over the time dimension.
              critic_loss = tf.reduce_sum(critic_loss, axis=1)
          if weights is not None:
              critic_loss *= weights
          critic_loss = tf.reduce_mean(critic_loss)
  
          with tf.name_scope("Losses/"):
              tf.compat.v2.summary.scalar(
                  name="critic_loss",
                  data=critic_loss,
                  step=self.train_step_counter,
              )
  
          if self._debug_summaries:
              td_errors = td_targets - q_values
              common.generate_tensor_summaries(
                  "td_errors", td_errors, self.train_step_counter
              )
              common.generate_tensor_summaries(
                  "td_targets", td_targets, self.train_step_counter
              )
              common.generate_tensor_summaries(
                  "q_values", q_values, self.train_step_counter
              )
  
          return critic_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 7 for calling the DdpgAgent obj's underlying member method code with example usage: obj.critic_loss(time_steps, actions, next_time_steps, weights, training) and returns: critic_loss