//  [python]
def _prune_weight(self, op, weight_tensor, scope):
        with tf.variable_scope(scope, reuse=tf.AUTO_REUSE):
            weight_variable = get_variable_by_tensor(weight_tensor)
            m = self._prune_var_mask_abs_grads[weight_variable]

            if op.type == 'DepthwiseConv2dNative':
                m = m.transpose((0, 1, 3, 2))
            
            mask = None
            
            if weight_variable in self._pname_gt_reshape_mean_constants.keys():
                gt_reshape_mean_const = self._pname_gt_reshape_mean_constants[weight_variable]
                gt_reshape_mean_flatten_const = self._pname_gt_reshape_mean_flatten_constants[weight_variable]

                argsorted = tf.contrib.framework.argsort(gt_reshape_mean_flatten_const)
                local_threshold_index = tf.to_float(tf.size(gt_reshape_mean_const)) * self._config_dict[op.name] * tf.to_float(self._step) / self._total_pruning_iterations
                local_threshold_index = tf.to_int64(local_threshold_index)
                ones = lambda: tf.ones_like(gt_reshape_mean_flatten_const)
                mask = tf.get_variable(name='mask', initializer=ones, trainable=False)
                tf.add_to_collection("init_masks", mask)
                # mask = tf.ones_like(gt_reshape_mean.flatten())
                # mask[argsorted[0:local_threshold_index]] = 0.
                update_indices = argsorted[0:local_threshold_index]
                update_values = tf.cast(tf.zeros_like(update_indices), tf.float32)
                mask = tf.scatter_nd_update(mask, tf.reshape(update_indices, [local_threshold_index, 1]), update_values)
                mask = tf.reshape(mask, gt_reshape_mean_const.shape)

                mask = tf.concat([mask, mask, mask, mask], axis=1)
                oc_blocks = m.shape[-1] // 4
                block_total_rows = oc_blocks * 4
                mask = tf.reshape(mask, [-1, block_total_rows])

            if weight_variable in self._pname_gt_remains_reshape_mean_constants.keys():
                gt_remains_reshape_mean_const = self._pname_gt_remains_reshape_mean_constants[weight_variable]
                gt_remains_reshape_mean_flatten_const = self._pname_gt_remains_reshape_mean_flatten_constants[weight_variable]

                argsorted = tf.contrib.framework.argsort(gt_remains_reshape_mean_flatten_const)
                local_threshold_index = tf.to_float(tf.size(gt_remains_reshape_mean_const)) * self._config_dict_constants[op.name] * tf.to_float(self._step) / self._total_pruning_iterations
                local_threshold_index = tf.to_int64(local_threshold_index)
                ones = lambda: tf.ones_like(gt_remains_reshape_mean_flatten_const)
                remain_mask = tf.get_variable(name='remain_mask', initializer=ones, trainable=False)
                tf.add_to_collection("init_masks", remain_mask)
                # remain_mask = tf.ones_like(tf.layers.flatten(gt_remains_reshape_mean_const))
                # remain_mask[argsorted[0:local_threshold_index]] = 0.
                update_indices = argsorted[0:local_threshold_index]
                update_values = tf.cast(tf.zeros_like(update_indices), tf.float32)
                remain_mask = tf.scatter_nd_update(remain_mask, tf.reshape(update_indices, [local_threshold_index, 1]), update_values)
                remain_mask = tf.reshape(remain_mask, gt_remains_reshape_mean_const.shape)

                remains = m.shape[-1] % 4
                remain_mask = tf.concat([remain_mask for x in range(0, remains)], axis=1)

                if mask is not None:
                    mask = tf.concat([mask, remain_mask], axis=1)
                else:
                    mask = remain_mask

            mask = tf.reshape(mask, m.shape)

            if op.type == 'DepthwiseConv2dNative':
                mask = tf.transpose(mask, (0, 1, 3, 2))

            self._mask_dict[op.name] = mask

            if self._debug_info:
                pruning_ratio = 1.0 - tf.reduce_mean(mask)
                print_op = tf.print("pruning iter:", self._step, "/", self._total_pruning_iterations, op.name, "pruning_ratio:", pruning_ratio)

                with tf.control_dependencies([print_op]):
                    pruned_weight_tensor = weight_variable * mask
            else:
                pruned_weight_tensor = weight_variable * mask

            new_weight_tensor_assign = tf.assign(weight_variable, pruned_weight_tensor)
            tf.add_to_collection("update_pruning_masks", new_weight_tensor_assign)

            return new_weight_tensor_assign