code: def ref_func_prune(x, rate):
      n = x.size
      shape = x.shape
      x = x.flatten()
      thresh_idx = int((n - 1) * rate)
      thresh_val = np.sort(np.abs(x))[thresh_idx]
      thresh_val = thresh_val + 1.0 if rate == 1.0 else thresh_val
      idx = np.where(np.abs(x) < thresh_val)
      y = np.copy(x)
      y[idx] = 0.0
      y = y.reshape(shape)
      return y
  
file_path: nnabla/python/test/function/test_prune.py
imports: import pytest
  import numpy
  import nnabla.functions
  from nbla_test_utils import list_context
label_desc: Use image node_id 1 for calling a global function with example usage: ref_func_prune(x, rate) and returns: y