code: def apply_activation(
      books,
      x,
      activation,
      activation_args=(),
      activation_kwargs=None):
    
    if activation is None:
      return x
    if activation_kwargs is None:
      activation_kwargs = {}
    y = activation(x, *activation_args, **activation_kwargs)
    if activation in (tf.nn.relu, functions.leaky_relu, functions.softplus):
      books.add_scalar_summary(
          tf.reduce_mean(tf.cast(tf.less(x, 0.0), tf.float32)),
          '%s/zeros' % y.op.name)
    elif activation is tf.nn.relu6:
      books.add_scalar_summary(
          tf.reduce_mean(tf.cast(tf.less(x, 0.0), tf.float32)),
          '%s/zeros' % y.op.name)
      books.add_scalar_summary(
          tf.reduce_mean(tf.cast(tf.greater(x, 6.0), tf.float32)),
          '%s/sixes' % y.op.name)
    elif activation in (functions.l2_normalize, tf.nn.l2_normalize,
                        functions.l1_normalize):
      books.add_scalar_summary(
          tf.reduce_mean(tf.sqrt(tf.reduce_sum(
              tf.square(x), 1))), '%s/length' % y.op.name)
    return y
docs: Returns activation(x, *activation_args, **activation_kwargs).
  
    This applies the given activation and adds useful summaries specific to the
    activation.
  
    Args:
      books: The bookkeeper.
      x: The tensor to apply activation to.
      activation: An activation function.
      activation_args: Optional additional arguments for the activation.
      activation_kwargs: Optional keyword args for activation.
    Returns:
      A tensor with activation applied to x.