code: def pruning_attn():
      Path("./output/bert_finetuned/").mkdir(
          parents=True, exist_ok=True
      )
      model = build_finetuning_model(
          task_name, f"./output/bert_finetuned/{task_name}.bin"
      )
      trainer = prepare_traced_trainer(model, task_name)
      evaluator = TransformersEvaluator(trainer)
  
      config_list = [
          {
              "op_types": ["Linear"],
              "op_names_re": [
                  "bert\.encoder\.layer\.[0-9]*\.attention\.*"
              ],
              "sparse_threshold": 0.1,
              "granularity": [64, 64],
          }
      ]
  
      pruner = MovementPruner(
          model,
          config_list,
          evaluator,
          warmup_step=9000,
          cooldown_begin_step=36000,
          regular_scale=10,
      )
      pruner.compress(None, 4)
      pruner.unwrap_model()
  
      masks = pruner.get_masks()
      Path("./output/pruning/").mkdir(parents=True, exist_ok=True)
      torch.save(masks, "./output/pruning/attn_masks.pth")
      torch.save(model, "./output/pruning/attn_masked_model.pth")
  
imports: from __future__ import annotations
  from pathlib import Path
  import numpy
  import torch
  from torch.utils.data import ConcatDataset
  import nni
  from datasets import load_dataset, load_metric
  from transformers import BertTokenizerFast, DataCollatorWithPadding, BertForSequenceClassification, EvalPrediction
  from transformers.trainer import Trainer
  from transformers.training_args import TrainingArguments
  from nni.compression.distillation import DynamicLayerwiseDistiller, Adaptive1dLayerwiseDistiller
  from nni.compression.utils import TransformersEvaluator
  from nni.compression.pruning import MovementPruner
  from nni.compression.speedup import ModelSpeedup
  from nni.compression.utils.external.external_replacer import TransformersAttentionReplacer
  from nni.compression.pruning import TaylorPruner, AGPPruner
  from transformers.models.bert.modeling_bert import BertLayer
  from nni.compression.base.setting import PruningSetting
label_desc: Use image node_id 9 for calling a global function with example usage: pruning_attn() without return types