code: def testCriticRegLoss(self):
      agent = sac_agent.SacAgent(
          self._time_step_spec,
          self._action_spec,
          critic_network=DummyCriticNet(0.5),
          actor_network=None,
          actor_optimizer=None,
          critic_optimizer=None,
          alpha_optimizer=None,
          actor_policy_ctor=DummyActorPolicy,
      )
  
      observations = tf.zeros((2, 2), dtype=tf.float32)
      time_steps = ts.restart(observations, batch_size=2)
      actions = tf.zeros((2, 1), dtype=tf.float32)
  
      rewards = tf.zeros((2,), dtype=tf.float32)
      discounts = tf.zeros((2,), dtype=tf.float32)
      next_observations = tf.zeros((2, 2), dtype=tf.float32)
      next_time_steps = ts.transition(
          next_observations, rewards, discounts
      )
  
      # Expected loss only regularization loss.
      expected_loss = 2.0
  
      loss = agent.critic_loss(
          time_steps,
          actions,
          next_time_steps,
          td_errors_loss_fn=tf.math.squared_difference,
      )
  
      self.evaluate(tf.compat.v1.global_variables_initializer())
      loss_ = self.evaluate(loss)
      self.assertAllClose(loss_, expected_loss)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from absl.testing import parameterized
  import mock
  import tensorflow
  from tf_agents.agents import test_util
  from tf_agents.agents.ddpg import critic_rnn_network
  from tf_agents.agents.sac import sac_agent
  from tf_agents.agents.sac import tanh_normal_projection_network
  from tf_agents.networks import actor_distribution_network
  from tf_agents.networks import actor_distribution_rnn_network
  from tf_agents.networks import nest_map
  from tf_agents.networks import network
  from tf_agents.networks import sequential
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import common
  from tf_agents.utils import test_utils
label_desc: Use image node_id 6 for calling the SacAgentTest obj's underlying member method code with example usage: obj.testCriticRegLoss() without return types