import tensorflow as tf

      name: Optional scope/name for op_scope.

  Returns:
      the l1+L2 loss op.
  """
  with tf.name_scope(name):
    weight_l1_t = tf.convert_to_tensor(weight_l1, dtype=var.dtype.base_dtype, name='weight_l1')
    weight_l2_t = tf.convert_to_tensor(weight_l2, dtype=var.dtype.base_dtype, name='weight_l2')
    reg_l1 = tf.multiply(weight_l1_t, tf.reduce_sum(tf.abs(var)), name='value_l1')
    reg_l2 = tf.multiply(weight_l2_t, tf.nn.l2_loss(var), name='value_l2')
    return tf.add(reg_l1, reg_l2, name='value')


def l1_regularizer(scale, name='l1_regularizer'):
  """Returns a function that can be used to apply L1 regularization to weights.
  L1 regularization encourages sparsity.
