code: def model_sparsity(
      model, param_dims=[2, 4], param_types=["weight", "bias"]
  ):
      """Returns the model sparsity as a fraction in [0..1]"""
      sparsity, _, _ = model_params_stats(
          model, param_dims, param_types
      )
      return sparsity
  
imports: import argparse
  from collections import OrderedDict
  from copy import deepcopy
  import logging
  import operator
  import random
  import numpy
  import torch
  import torch.nn
  import torch.backends.cudnn
  import yaml
  import inspect
label_desc: Use image node_id 27 for calling a global function with example usage: model_sparsity(model, param_dims, param_types) and returns: sparsity