code: def detect_mask_prune_dim(masks, model):
      """
      Detect how the masks of convolutional layers are pruned.
  
      Parameters
      ----------
      masks: dict
          A dict object that stores the masks.
      model: nn.Module
          Model object which the mask can be applied on.
  
      Returns:
      -------
          How the masks of convolutional layers are pruned, this depends on pruning algorithms, it should
          return 1 for masks generated by AMCPruner, and returns 0 for masks generated by the rest
          NNI builtin pruners.
          0: filter pruning, prune filters of weights which causes channels of output feature maps are pruned.
          1: channel pruning, prune kernels corresponding to each input channels which causes channels of
             input feature maps are pruned.
      """
      dim0_preserved, dim1_preserved = 0.0, 0.0
      dim0_num, dim1_num = 0.0, 0.0
      for module_name in masks:
          _, m = get_module_by_name(model, module_name)
          if m is None or type(m).__name__ != "Conv2d":
              continue
  
          mask = masks[module_name]["weight"].clone()
          assert (
              mask >= 0
          ).sum() == mask.numel(), (
              "mask values should be greater than or equal to 0."
          )
          mask = (mask > 0).int()
          mask = mask.view(mask.shape[0], mask.shape[1], -1)
          dim0_mask = (mask.sum((1, 2)) > 0).int()
          dim1_mask = (mask.sum((0, 2)) > 0).int()
          dim0_preserved += dim0_mask.sum().item()
          dim1_preserved += dim1_mask.sum().item()
          dim0_num += len(dim0_mask)
          dim1_num += len(dim1_mask)
  
      if dim0_num == 0 or dim1_num == 0:
          _logger.warning("no multi-dimension masks found.")
          return 0
  
      dim0_sparsity, dim1_sparsity = (
          1.0 - dim0_preserved / dim0_num,
          1.0 - dim1_preserved / dim1_num,
      )
      _logger.info("dim0 sparsity: %f", dim0_sparsity)
      _logger.info("dim1 sparsity: %f", dim1_sparsity)
  
      if dim0_sparsity == dim1_sparsity == 0.0:
          _logger.warning("nothing masked.")
  
      if dim0_sparsity > 0 and dim1_sparsity > 0:
          _logger.warning("both dim0 and dim1 masks found.")
  
      return 0 if dim0_sparsity >= dim1_sparsity else 1
  
imports: import os
  import logging
  import torch
  import numpy
  from .shape_dependency import ChannelDependency, GroupDependency, CatPaddingDependency, InputChannelDependency
  from .utils import get_module_by_name
label_desc: Use image node_id 2 for calling a global function with example usage: detect_mask_prune_dim(masks, model) and returns: unknown, int