code: def pruning_inplace(
      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,))
  
file_path: nnabla/python/test/utils/test_graph_converters/test_pruning.py
imports: from __future__ import absolute_import
  import pytest
  import numpy
  import nnabla
  import nnabla.experimental.graph_converters
  from nbla_test_utils import list_context
  from .ref_graphs.resnets import net_for_pruning, depthwise_net_for_pruning
label_desc: Use image node_id 1 for calling a global function with example usage: pruning_inplace(pred, threshold, functions_to_pruning, channel_last) without return types