def METHOD_NAME(pred, threshold, functions_to_pruning, channel_last=False):
    def traverse(l, var):
        if var.parent is not None and var.parent.info.type_name in functions_to_pruning:
            l.append(var.parent)
        if var.parent is not None:
            for ivar in var.parent.inputs:
                traverse(l, ivar)
    output_channel_axis = {
        'Affine': 1,
        'Convolution': 0,
        'Deconvolution': {
            True: -1,
            False: 1
        },
        'DepthwiseConvolution': 0,
        'DepthwiseDeconvolution': 0,
    }
    functions = []
    traverse(functions, pred)
    for func in functions:
        inputs = func.inputs
        x, w = inputs[:2]
        b = None
        if len(inputs) == 3:
            b = inputs[2]
        axis_to_sum = output_channel_axis[func.info.type_name]
        if not isinstance(axis_to_sum, int):
            axis_to_sum = axis_to_sum[channel_last]
        shape = list(range(w.ndim))
        shape.pop(axis_to_sum)
        l2_norm_per_channel = np.sum(
            w.d ** 2, axis=tuple(shape), keepdims=True)
        mask = l2_norm_per_channel > threshold
        w.d = w.d * mask
        if b is not None:
            b.d = b.d * mask.reshape((-1,))