<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def regularization(variables, regtype, regcoef, name="regularization"):
 """Compute the regularization tensor. Parameters variables : list of tf.Variable List of model variables. regtype : str Type of regularization. Can be ["none", "l1", "l2"] regcoef : float, Regularization coefficient. name : str, optional (default = "regularization") Name for the regularization op. Returns ------- tf.Tensor : Regularization tensor. """

        with tf.name_scope(name):
            if regtype != 'none':
                regs = tf.constant(0.0)
                for v in variables:
                    if regtype == 'l2':
                        regs = tf.add(regs, tf.nn.l2_loss(v))
                    elif regtype == 'l1':
                        regs = tf.add(regs, tf.reduce_sum(tf.abs(v)))

                return tf.multiply(regcoef, regs)
            else:
                return None