code: def count_sparsity(model: torch.nn.Module, p=True):
      sum_zeros_num = 0
      sum_weights_num = 0
      for name, module in model.named_modules():
          if isinstance(module, torch.nn.Conv2d):
              zeros_elements = torch.sum(
                  torch.eq(module.weight, 0)
              ).item()
              weights_elements = module.weight.numel()
  
              sum_zeros_num += zeros_elements
              sum_weights_num += weights_elements
              if p is True:
                  print(
                      "Sparsity in {}.weights {:.2f}%".format(
                          name, 100 * zeros_elements / weights_elements
                      )
                  )
      print(
          "Global sparsity: {:.2f}%".format(
              100 * sum_zeros_num / sum_weights_num
          )
      )
  
file_path: deep-learning-for-image-processing/deploying_service/pruning_model_pytorch/main.py
imports: import os
  import torch
  from torchvision import transforms, datasets
  import torch.nn.utils.prune
  import torch.nn.functional
  from tqdm import tqdm
  import time
  from model import resnet34
label_desc: Use image node_id 2 for calling a global function with example usage: count_sparsity(model, p) without return types