code: def __call__(self, model):
      # FIXME: adapt to network graph when Training and inference are
      # inconsistent, now only supports prune inference network graph.
      model.eval()
      paddleslim = try_import("paddleslim")
      from paddleslim.analysis import dygraph_flops as flops
  
      input_spec = [
          {
              "image": paddle.ones(
                  shape=[1, 3, 640, 640], dtype="float32"
              ),
              "im_shape": paddle.full([1, 2], 640, dtype="float32"),
              "scale_factor": paddle.ones(
                  shape=[1, 2], dtype="float32"
              ),
          }
      ]
      if self.print_prune_params:
          print_prune_params(model)
  
      ori_flops = flops(model, input_spec) / 1000
      logger.info("FLOPs before pruning: {}GFLOPs".format(ori_flops))
      if self.criterion == "fpgm":
          pruner = paddleslim.dygraph.FPGMFilterPruner(
              model, input_spec
          )
      elif self.criterion == "l1_norm":
          pruner = paddleslim.dygraph.L1NormFilterPruner(
              model, input_spec
          )
  
      logger.info("pruned params: {}".format(self.pruned_params))
      pruned_ratios = [float(n) for n in self.pruned_ratios]
      ratios = {}
      for i, param in enumerate(self.pruned_params):
          ratios[param] = pruned_ratios[i]
      pruner.prune_vars(ratios, [0])
      pruned_flops = flops(model, input_spec) / 1000
      logger.info(
          "FLOPs after pruning: {}GFLOPs; pruned ratio: {}".format(
              pruned_flops, (ori_flops - pruned_flops) / ori_flops
          )
      )
  
      self.quanter = paddleslim.dygraph.quant.QAT(
          config=self.quant_config
      )
  
      self.quanter.quantize(model)
  
      if self.print_qat_model:
          logger.info("Quantized model:")
          logger.info(model)
  
      return model
  
file_path: PaddleDetection/ppdet/slim/prune.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle.utils import try_import
  from ppdet.core.workspace import register, serializable
  from ppdet.utils.logger import setup_logger
label_desc: Use image node_id 2 for calling the PrunerQAT obj's underlying member method code with example usage: obj.__call__(model) and returns: model