class_docstr: A PPO Agent.
class_docstr_tok: ["A","PPO","Agent","."]
code: def l2_regularization_loss(
      self, debug_summaries: bool = False
  ) -> types.Tensor:
      if (
          self._policy_l2_reg > 0
          or self._value_function_l2_reg > 0
          or self._shared_vars_l2_reg > 0
      ):
          with tf.name_scope("l2_regularization"):
              # Regularize policy weights.
              policy_vars_to_regularize = (
                  v
                  for v in self._actor_net.trainable_weights
                  if "kernel" in v.name
              )
              vf_vars_to_regularize = (
                  v
                  for v in self._value_net.trainable_weights
                  if "kernel" in v.name
              )
  
              (
                  unshared_policy_vars_to_regularize,
                  unshared_vf_vars_to_regularize,
                  shared_vars_to_regularize,
              ) = common.extract_shared_variables(
                  policy_vars_to_regularize, vf_vars_to_regularize
              )
  
              # Regularize policy weights.
              policy_l2_losses = [
                  common.aggregate_losses(
                      regularization_loss=tf.square(v)
                  ).regularization
                  * self._policy_l2_reg
                  for v in unshared_policy_vars_to_regularize
              ]
  
              # Regularize value function weights.
              vf_l2_losses = [
                  common.aggregate_losses(
                      regularization_loss=tf.square(v)
                  ).regularization
                  * self._value_function_l2_reg
                  for v in unshared_vf_vars_to_regularize
              ]
  
              # Regularize shared weights
              shared_l2_losses = [
                  common.aggregate_losses(
                      regularization_loss=tf.square(v)
                  ).regularization
                  * self._shared_vars_l2_reg
                  for v in shared_vars_to_regularize
              ]
  
              l2_losses = (
                  policy_l2_losses + vf_l2_losses + shared_l2_losses
              )
              total_l2_loss = tf.add_n(l2_losses, name="l2_loss")
  
              if self._check_numerics:
                  total_l2_loss = tf.debugging.check_numerics(
                      total_l2_loss, "total_l2_loss"
                  )
  
              # TODO(b/171573175): remove the condition once histograms are
              # supported on TPUs.
              if (
                  debug_summaries
                  and not tf.config.list_logical_devices("TPU")
              ):
                  tf.compat.v2.summary.histogram(
                      name="l2_loss",
                      data=total_l2_loss,
                      step=self.train_step_counter,
                  )
      else:
          total_l2_loss = tf.constant(
              0.0, dtype=tf.float32, name="zero_l2_loss"
          )
  
      return total_l2_loss
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Optional, Text, Tuple
  from absl import logging
  import gin
  from six.moves import range
  from six.moves import zip
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.agents.ppo import ppo_policy
  from tf_agents.agents.ppo import ppo_utils
  from tf_agents.networks import network
  from tf_agents.policies import greedy_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  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
  from tf_agents.utils import object_identity
  from tf_agents.utils import tensor_normalizer
  from tf_agents.utils import value_ops
label_desc: Use image node_id 12 for calling the PPOAgent obj's underlying member method code with example usage: obj.l2_regularization_loss(debug_summaries) and returns: total_l2_loss