code: def adapt_distiller(
      student_model: BertForSequenceClassification,
      teacher_model: BertForSequenceClassification,
      student_trainer: Trainer,
  ):
      layer_num = len(student_model.bert.encoder.layer)
      config_list = [
          {
              "op_names": [f"bert.encoder.layer.{i}"],
              "lambda": 0.9,
              "apply_method": "mse",
          }
          for i in range(layer_num)
      ]
      config_list.append(
          {
              "op_names": ["classifier"],
              "link": ["classifier"],
              "lambda": 0.9,
              "apply_method": "kl",
          }
      )
  
      evaluator = TransformersEvaluator(student_trainer)
  
      def teacher_predict(batch, teacher_model):
          return teacher_model(**batch)
  
      return Adaptive1dLayerwiseDistiller(
          student_model,
          config_list,
          evaluator,
          teacher_model,
          teacher_predict,
          origin_loss_lambda=0.1,
      )
  
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 7 for calling a global function with example usage: adapt_distiller(student_model, teacher_model, student_trainer) and returns: Adaptive1dLayerwiseDistiller, teacher_model