class_docstr: Base class for modules.
  
  Args:
      device (string): Device name
          (<span style="color:#00C000"><b>default</b></span>: inherit value of parent module).
      l2_regularization (float >= 0.0): Scalar controlling L2 regularization
          (<span style="color:#00C000"><b>default</b></span>: inherit value of parent module).
      name (string): <span style="color:#0000C0"><b>internal use</b></span>.
code: def regularize(self):
      zero = tf_util.constant(value=0.0, dtype="float")
  
      module = self
      while module.l2_regularization is None:
          module = module.parent
  
      if len(
          self.this_trainable_variables
      ) == 0 or module.l2_regularization.is_constant(value=0.0):
          regularization_loss = zero
  
      else:
          l2_regularization = module.l2_regularization.value()
  
          def no_l2_regularization():
              return zero
  
          def apply_l2_regularization():
              l2_variables = list()
              for variable in self.this_trainable_variables:
                  variable = tf_util.cast(x=variable, dtype="float")
                  l2_variables.append(
                      tf.reduce_sum(input_tensor=tf.square(x=variable))
                  )
              return l2_regularization * tf.math.add_n(
                  inputs=l2_variables
              )
  
          skip_l2_regularization = tf.math.equal(
              x=l2_regularization, y=zero
          )
          regularization_loss = tf.cond(
              pred=skip_l2_regularization,
              true_fn=no_l2_regularization,
              false_fn=apply_l2_regularization,
          )
  
      for module in self.this_submodules:
          if isinstance(module, Module) and module.is_trainable:
              regularization_loss += module.regularize()
  
      return regularization_loss
  
imports: import functools
  import json
  import os
  import re
  import numpy
  import tensorflow
  from tensorforce import TensorforceError, util
  import tensorforce.core
  from tensorforce.core import SignatureDict, TensorSpec, tf_util, VariableDict
label_desc: Use image node_id 17 for calling the Module obj's underlying member method code with example usage: obj.regularize() and returns: regularization_loss, zero, unknown