<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def L2(layer="input", constant=0, epsilon=1e-6, batch=None):
 """L2 norm of layer. Generally used as penalty."""

  if batch is None:
    return lambda T: tf.sqrt(epsilon + tf.reduce_sum((T(layer) - constant) ** 2))
  else:
    return lambda T: tf.sqrt(epsilon + tf.reduce_sum((T(layer)[batch] - constant) ** 2))