code: def get_model_weights_numel(
      model: Module,
      config_list: List[Dict],
      masks: Dict[str, Dict[str, Tensor]] = {},
  ) -> Tuple[Dict[str, int], Dict[str, float]]:
      """
      Count the layer weight elements number in config_list.
      If masks is not empty, the masked weight will not be counted.
      """
      model_weights_numel = {}
      masked_rate = {}
      for config in config_list:
          for module_name, module in model.named_modules():
              module_type = type(module).__name__
              if (
                  "op_types" in config
                  and module_type not in config["op_types"]
              ):
                  continue
              if (
                  "op_names" in config
                  and module_name not in config["op_names"]
              ):
                  continue
              if module_name in masks and isinstance(
                  masks[module_name]["weight"], Tensor
              ):
                  weight_mask = masks[module_name]["weight"]
                  masked_rate[module_name] = 1 - (
                      weight_mask.sum().item() / weight_mask.numel()
                  )
                  model_weights_numel[module_name] = round(
                      weight_mask.sum().item()
                  )
              else:
                  model_weights_numel[module_name] = module.weight.data.numel()  # type: ignore
      return model_weights_numel, masked_rate
  
file_path: nni/nni/compression/utils/mask_counter.py
imports: from copy import deepcopy
  import math
  from typing import Dict, List, Tuple
  import torch
  from torch import Tensor
  from torch.nn import Module
label_desc: Use image node_id 4 for calling a global function with example usage: get_model_weights_numel(model, config_list, masks) and returns: model_weights_numel,  masked_rate